如何在vb中实现桌面背景的设置???
如何在vb中实现桌面背景的设置???我只是知道可以从vb中调用桌面属性进行设置,有没有办法直接通过打钩选定直接进入系统更改参数实现???...
如何在vb中实现桌面背景的设置???
我只是知道可以从vb中调用桌面属性进行设置,有没有办法直接通过打钩选定直接进入系统更改参数实现??? 展开
我只是知道可以从vb中调用桌面属性进行设置,有没有办法直接通过打钩选定直接进入系统更改参数实现??? 展开
1个回答
展开全部
以下代码可以达到你的要求:
(可以定时更换墙纸)
Private Sub Timer1_Timer() '一分钟循环一次
Dim FileName As String
Dim Ret As Long
Dim MyValue As Integer
If ListFile.ListCount > 0 And (TimeCount Mod TimeValue) = 0 Then '更换为选定的墙纸
If Option1.Value = True Then '顺序更换
If FileNum > ListFile.ListCount Then FileNum = 1
FileName = ListFile.List(FileNum - 1)
FileNum = FileNum + 1
ElseIf Option2.Value = True Then '随机更换
Randomize ' 对随机数生成器做初始化的动作
MyValue = Int(ListFile.ListCount * Rnd) ' 生成 0 到 LISTBOX中数目和(ListCount-1个)之间的随机数值。
FileName = ListFile.List(MyValue)
End If
If fs.FileExists(FileName) Then '文件是否存在
If Option3.Value = True Then '平铺
rc = RegOpenKeyEx(HKEY_CURRENT_USER, gREGKEYWallPaper, 0, KEY_ALL_ACCESS, hKey) '打开相应注册键值
rc = RegSetValueEx(hKey, "TileWallpaper", 0, REG_SZ, ByVal "1", 2) '写入相应键值信息
rc = RegSetValueEx(hKey, "WallpaperStyle", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
Ret = WritePrivateProfileString("Desktop", "Wallpaper", FileName, "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "TileWallpaper", "1", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "WallpaperStyle", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, ByVal FileName, SPIF_UPDATEINIFILE) '更新系统参数信息
ElseIf Option4.Value = True Then '拉伸
rc = RegOpenKeyEx(HKEY_CURRENT_USER, gREGKEYWallPaper, 0, KEY_ALL_ACCESS, hKey) '打开相应注册键值
rc = RegSetValueEx(hKey, "TileWallpaper", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
rc = RegSetValueEx(hKey, "WallpaperStyle", 0, REG_SZ, ByVal "2", 2) '写入相应键值信息
Ret = WritePrivateProfileString("Desktop", "Wallpaper", FileName, "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "TileWallpaper", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "WallpaperStyle", "2", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, ByVal FileName, SPIF_UPDATEINIFILE) '更新系统参数信息
ElseIf Option5.Value = True Then '居中
rc = RegOpenKeyEx(HKEY_CURRENT_USER, gREGKEYWallPaper, 0, KEY_ALL_ACCESS, hKey) '打开相应注册键值
rc = RegSetValueEx(hKey, "TileWallpaper", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
rc = RegSetValueEx(hKey, "WallpaperStyle", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
Ret = WritePrivateProfileString("Desktop", "Wallpaper", FileName, "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "TileWallpaper", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "WallpaperStyle", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, ByVal FileName, SPIF_UPDATEINIFILE) '更新系统参数信息
End If
End If
End If
TimeCount = TimeCount + 1 '因为计数器时间间隔不能大于65535毫秒,故采取此计数法
End Sub
(可以定时更换墙纸)
Private Sub Timer1_Timer() '一分钟循环一次
Dim FileName As String
Dim Ret As Long
Dim MyValue As Integer
If ListFile.ListCount > 0 And (TimeCount Mod TimeValue) = 0 Then '更换为选定的墙纸
If Option1.Value = True Then '顺序更换
If FileNum > ListFile.ListCount Then FileNum = 1
FileName = ListFile.List(FileNum - 1)
FileNum = FileNum + 1
ElseIf Option2.Value = True Then '随机更换
Randomize ' 对随机数生成器做初始化的动作
MyValue = Int(ListFile.ListCount * Rnd) ' 生成 0 到 LISTBOX中数目和(ListCount-1个)之间的随机数值。
FileName = ListFile.List(MyValue)
End If
If fs.FileExists(FileName) Then '文件是否存在
If Option3.Value = True Then '平铺
rc = RegOpenKeyEx(HKEY_CURRENT_USER, gREGKEYWallPaper, 0, KEY_ALL_ACCESS, hKey) '打开相应注册键值
rc = RegSetValueEx(hKey, "TileWallpaper", 0, REG_SZ, ByVal "1", 2) '写入相应键值信息
rc = RegSetValueEx(hKey, "WallpaperStyle", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
Ret = WritePrivateProfileString("Desktop", "Wallpaper", FileName, "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "TileWallpaper", "1", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "WallpaperStyle", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, ByVal FileName, SPIF_UPDATEINIFILE) '更新系统参数信息
ElseIf Option4.Value = True Then '拉伸
rc = RegOpenKeyEx(HKEY_CURRENT_USER, gREGKEYWallPaper, 0, KEY_ALL_ACCESS, hKey) '打开相应注册键值
rc = RegSetValueEx(hKey, "TileWallpaper", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
rc = RegSetValueEx(hKey, "WallpaperStyle", 0, REG_SZ, ByVal "2", 2) '写入相应键值信息
Ret = WritePrivateProfileString("Desktop", "Wallpaper", FileName, "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "TileWallpaper", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "WallpaperStyle", "2", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, ByVal FileName, SPIF_UPDATEINIFILE) '更新系统参数信息
ElseIf Option5.Value = True Then '居中
rc = RegOpenKeyEx(HKEY_CURRENT_USER, gREGKEYWallPaper, 0, KEY_ALL_ACCESS, hKey) '打开相应注册键值
rc = RegSetValueEx(hKey, "TileWallpaper", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
rc = RegSetValueEx(hKey, "WallpaperStyle", 0, REG_SZ, ByVal "0", 2) '写入相应键值信息
Ret = WritePrivateProfileString("Desktop", "Wallpaper", FileName, "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "TileWallpaper", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = WritePrivateProfileString("Desktop", "WallpaperStyle", "0", "Win.ini") '更换结果写入到Win.ini中相应相置
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, ByVal FileName, SPIF_UPDATEINIFILE) '更新系统参数信息
End If
End If
End If
TimeCount = TimeCount + 1 '因为计数器时间间隔不能大于65535毫秒,故采取此计数法
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询