»áÔ±£º ÃÜÂ룺 ¡¡Ãâ·Ñ×¢²á | Íü¼ÇÃÜÂë | »áÔ±µÇ¼ ÍøÒ³¹¦ÄÜ£º ¼ÓÈëÊÕ²Ø ÉèΪÊ×Ò³ ÍøÕ¾ËÑË÷  
 °²È«¼¼Êõ¼¼ÊõÎĵµ
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ºÚ¿Í½Ìѧ
  ¡¤ ·À»ðǽ
  ¡¤ Â©¶´·ÖÎö
  ¡¤ ÆƽâרÌâ
  ¡¤ ºÚ¿Í±à³Ì
  ¡¤ ÈëÇÖ¼ì²â
 °²È«¼¼ÊõÂÛ̳
  ¡¤ °²È«ÅäÖÆ
  ¡¤ ¹¤¾ß½éÉÜ
  ¡¤ ·À»ðǽ
  ¡¤ ºÚ¿ÍÈëÇÖ
  ¡¤ Â©¶´¼ì²â
  ¡¤ Æƽⷽ·¨
  ¡¤ É±¶¾×¨Çø
 °²È«¼¼Êõ¹¤¾ßÏÂÔØ
  ¡¤ É¨Ã蹤¾ß
  ¡¤ ¹¥»÷³ÌÐò
  ¡¤ ºóÃÅľÂí
  ¡¤ ¾Ü¾ø·þÎñ
  ¡¤ ¿ÚÁîÆƽâ
  ¡¤ ´úÀí³ÌÐò
  ¡¤ ·À»ðǽ
  ¡¤ ¼ÓÃܽâÃÜ
  ¡¤ ÈëÇÖ¼ì²â
  ¡¤ ¹¥·ÀÑÝʾ
¼¼ÊõÎĵµ > VBÎĵµ > ϵͳ¿ØÖÆ
ÓÃVB¸ü»»×ÀÃæǽֽDIY
·¢±íÈÕÆÚ£º2003-06-23 00:00:00×÷Õߣº¶ ³ö´¦£º  

¡¡¡¡ÔÚ¿Í»§ÔËÐÐÄúµÄÓ¦ÓóÌÐòµÄʱºò×Ô¶¯¸ü»»Ç½Ö½£¬ÏÔÈ»Êǹã¸æÐû´«µÄÒ»¸öºÃ»ú»á¡£µ«ÎÞÂÛÊÇ

MSDN»¹ÊÇÍøÂçÉϵÄÃâ·Ñ×ÊÔ´´úÂ룬¸ü»»Ç½Ö½¼¸ºõ¶¼ÊÇͬһ¸öAPIº¯ÊýSystemParametersInfoºÍͬ

Ò»¶Î´úÂ룬¹úÍâÕ¾µãÌṩµÄÃâ·Ñ´úÂëÒ²ÊÇÈç´Ë¡£´ÓVB4.0¿ªÊ¼¾ÍÕâÑù¡£Õâ¶Î´úÂëÊÇ£º

Private Declare Function SystemParametersInfo Lib "user32" Alias 

¡¡"SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ¡¡¡¡

ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

Const SPI_SETDESKWALLPAPER = 20

Const SPIF_SENDWININICHANGE = &H2

Const SPIF_UPDATEINIFILE = &H1

Private Sub Form_Load()

¡¡¡¡ChangeWP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ 0, "Path+BmpFile", 0)

End Sub 

¡¡¡¡Ê¹ÓÃÕâ¸öÀý³ÌȷʵÄܹ»Çл»Ç½Ö½£¬µ«´æÔÚÒÔÏÂÎÊÌ⣺

¡¡¡¡1¡¢ÓÃÊó±êÓÒ¼üµã»÷×ÀÃ棬»á¿´µ½¡¾±³¾°¡¿¡ú¡¾Ç½Ö½¡¿ÀïÃæµÄÎļþÃûÊǿյġ£

¡¡¡¡2¡¢ÖØÐÂÆô¶¯ºó×ÀÃæǽֽÏûʧ¡£

¡¡¡¡3¡¢Ã»¸æËßÄúÔõôÇл»"¾ÓÖÐ"»ò"ƽÆÌ"¡£

¡¡¡¡Ôõô½â¾öÕâЩÎÊÌâÄØ£¿

¡¡¡¡1¡¢WindowsµÄǽֽ±ØÐëÒÔBMP¸ñʽµÄÎļþ´æ·ÅÔÚWindowsĿ¼ÏÂÃ棬Èç¹ûÄúµÄͼƬ²»ÔÚ¸ÃĿ¼

»ò²»ÊÇBMPÎļþ£¬ÄÇô¾Í»á³öÏÖµÚÒ»¸öÎÊÌâ¡£Òò´Ë±ØÐë°ÑÄúµÄͼƬת»»³ÉBMPÎļþ²¢¸´ÖƵ½Windows

Ŀ¼ÏÂÃæ¡£

¡¡¡¡2¡¢ÒªÊ¹ÖØÐÂÆô¶¯ºóÐèÒªÔÚ×¢²á±íÀïÃæÐÞ¸ÄÏàÓ¦µÄ¼üÖµ£¬¾ßÌåλÖÃÊÇ 

HKEY_CURRENT_USER\Control Panel\desktopÖеÄWallpaper¼ü£¬ÈÃËüµÄ¼üÖµµÈÓÚÄúµÄȫ·¾¶ÎÄ

¼þÃû¡£

¡¡¡¡3¡¢ÔÚ¸ü»»Ç½Ö½ÒÔÇ°Ê×ÏÈÉèÖÃÊÇ·ñ"¾ÓÖÐ"£¬ÐèÒªÐÞ¸Ä×¢²á±íÖÐHKEY_CURRENT_USER\Control 

Panel\desktopÖеÄTileWallpaper¼ü£¬¼üÖµ"0"±íʾ"¾ÓÖÐ"£¬"1"±íʾ"ƽÆÌ"¡£

¡¡¡¡±¾Àý°ÑÒ»¸öJPG¸ñʽµÄͼƬ³É¹¦µØÉèÖÃΪǽֽ£¬È«²¿´úÂëÈçÏ£º

Private Declare Function GetWindowsDirectory Lib "kernel32" 

Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As 

Long

Private Declare Function SystemParametersInfo Lib "user32" 

Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, 

ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

Const SPI_SETDESKWALLPAPER = 20

Const SPIF_SENDWININICHANGE = &H2

Const SPIF_UPDATEINIFILE = &H1

Const REG_SZ As Long = 1

Const HKEY_CURRENT_USER = &H80000001

Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As 

Long

Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" 

(ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal 

samDesired As Long, phkResult As Long) As Long

Private Declare Function RegSetValueExString Lib "advapi32.dll" 

Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal 

Reserved As Long, ByVal dwType As Long, ByVal lpValue As String, ByVal cbData 

As Long) As Long

Private Declare Function RegSetValueExLong Lib "advapi32.dll" 

Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal 

Reserved As Long, ByVal dwType As Long, lpValue As Long, ByVal cbData As Long) 

As Long

Private Sub SetKeyValue(sKeyName As String, sValueName As String, vValueSetting 

As Variant, lValueType As Long, lPredefinedKey As Long)

¡¡lRetVal = RegOpenKeyEx(lPredefinedKey, sKeyName, 0, 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ KEY_ALL_ACCESS, hKey)

¡¡lRetVal = SetValueEx(hKey, sValueName, lValueType, vValueSetting)

¡¡RegCloseKey (hKey)

End Sub

Private Function SetValueEx(ByVal hKey As Long, sValueName As String, lType As 

Long, vValue As Variant) As Long

¡¡Dim lValue As Long

¡¡Dim sValue As String

¡¡Select Case lType

¡¡¡¡Case REG_SZ

¡¡¡¡¡¡¡¡¡¡sValue = vValue & Chr$(0)

¡¡¡¡¡¡¡¡¡¡SetValueEx = RegSetValueExString(hKey, sValueName, 0&, lType, 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ sValue, Len(sValue))

¡¡¡¡Case REG_DWORD, REG_BINARY

¡¡¡¡¡¡¡¡¡¡lValue = vValue

¡¡¡¡¡¡¡¡¡¡SetValueEx = RegSetValueExLong(hKey, sValueName, 0&, 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ lType, lValue, 4)

¡¡End Select

End Function

Private Sub Form_Load()

'È¡µÃwindowsĿ¼

¡¡Dim Path As String, strSave As String

¡¡strSave = String(50, Chr$(0))

¡¡Path = Left$(strSave, GetWindowsDirectory(strSave, Len(strSave)))

¡¡'ת»»Í¼Æ¬²¢±£´æµ½WindowsĿ¼ÏÂÃæ

¡¡Image1.Picture = LoadPicture(App.Path & "\MyFlower.Jpg")

¡¡SavePicture Image1, Path & "\MyFlower.bmp"

¡¡Dim aa As String

¡¡'дÈë×¢²á±í

¡¡'É趨¾ÓÖÐ

¡¡SetKeyValue "Control Panel\desktop", "TileWallpaper", 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡ "0", REG_SZ, HKEY_CURRENT_USER

¡¡'É趨ƽÆÌ

¡¡' SetKeyValue "Control Panel\desktop", 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ "TileWallpaper", "1", REG_SZ, HKEY_CURRENT_USER

¡¡'¸ü»»Ç½Ö½

¡¡aa = Path & "\MyFlower.bmp"

¡¡ChangeWP = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, aa, 0)

¡¡'ÔÚ×¢²á±íÖмǼͼƬλÖÃ

¡¡SetKeyValue "Control Panel\desktop", "Wallpaper", aa, 

¡¡¡¡¡¡¡¡¡¡¡¡¡¡ REG_SZ, HKEY_CURRENT_USER

End Sub 

¡¡¡¡Ê¹Óñ¾ÀýҪעÒ⣺±ØÐëÏÈÉèÖÃÊÇ·ñ"¾ÓÖÐ"£¬È»ºóÔÙ¸ü»»Ç½Ö½¡£±¾ÀýÔÚWindows95+VB6ϵ÷ÊÔͨ

¹ý¡£

¡¾·µ»Ø¶¥²¿¡¿ ¡¾´òÓ¡±¾Ò³¡¿ ¡¾¹Ø±Õ´°¿Ú¡¿

¹ØÓÚÎÒÃÇ / ¸øÎÒÁôÑÔ / °æȨ¾Ù±¨ / Òâ¼û½¨Òé / ÍøÕ¾±à³ÌQQȺ   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net ¼ÓÔØʱ¼ä 0.00178