|
-
Feb 21st, 2001, 02:27 PM
#1
Thread Starter
New Member
How can I set the windows wallpaper to my picture by VB code?
THANK YOU!
-
Feb 21st, 2001, 02:50 PM
#2
Try this:
Code:
Private Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal _
lpApplicationName As String, ByVal lpKeyName As String, _
ByVal lpDefault As String, ByVal lpReturnedString As _
String, ByVal nSize As Long, ByVal lpFileName As String) As _
Long
Private Function ReadINI(strsection As String, strkey As String, strfullpath As String) As String
Dim strbuffer As String
Let strbuffer$ = String$(750, Chr$(0&))
Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
End Function
Private Sub Form_Load()
Picture1.Picture = LoadPicture(ReadINI("Desktop", "Wallpaper", "C:\Windows\Win.INI"))
End Sub
-
Feb 21st, 2001, 02:55 PM
#3
Thread Starter
New Member
I'm sorry, Matthew.
In reality I want to set my picture to the windows wallpaper.
I want to change the windows wallpaper, by VB code.
Thank you!
-
Feb 21st, 2001, 05:03 PM
#4
Code:
Private Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal _
lpApplicationName As String, ByVal lpKeyName As Any, ByVal _
lpString As Any, ByVal lpFileName As String) As Long
Private Sub WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
End Sub
Private Sub Form_Load()
Call WriteINI("Desktop", "Wallpaper", "C:\MyPic.bmp", "C:\Windows\Win.INI")
End Sub
-
Feb 21st, 2001, 05:13 PM
#5
Fanatic Member
Hey Matthew when you are writing to the Win.ini file you can just use the WriteProfileString function....
Code:
Option Explicit
Private Declare Function WriteProfileString Lib "kernel32" Alias "WriteProfileStringA" (ByVal lpszSection As String, ByVal lpszKeyName As String, ByVal lpszString As String) As Long
Private Sub WriteWinINI(strsection As String, strkey As String, strkeyvalue As String)
Call WriteProfileString(strsection$, UCase$(strkey$), strkeyvalue$)
End Sub
Private Sub Form_Load()
Call WriteWinINI("Desktop", "Wallpaper", "C:\Windows\Forest.bmp")
End Sub
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 22nd, 2001, 07:30 AM
#6
Thread Starter
New Member
Thank you, guys, by your attention. But it doesn't work.
I changed the win.ini file (by your code) but it doesn't changed the Register (in Register Editor).
I think that is missing something.
[]'s
-
Feb 24th, 2001, 12:49 AM
#7
Member
Visit Here, download the demo... it works.
http://www.vb-world.net/demos/wallpaper/
-
Feb 24th, 2001, 09:04 PM
#8
Member
Try this code
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_UPDATEINIFILE = &H1
Const SPIF_SENDWININICHANGE = &H2
dim a as Long,strFileName as String
strFileName="c:\windows\desktop\a.bmp"
a = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, strFileName, SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|