I'm using this code to choose a random picture from a folder that I have selected and then change the wallpaper to it. The problem is that the wallpaper doesn't actually change. What have I done wrong?
VB Code:
Public 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 Sub Main() Dim pic() As String Dim file As String Dim path As String Dim count As Integer Dim i As Integer Randomize Timer path = "C:\Windows\Desktop\Graphics\Desktops\" file = Dir(path) Do While file <> "" If file <> "." And file <> ".." Then ReDim Preserve pic(count) pic(count) = file count = count + 1 End If file = Dir Loop i = Round(Rnd * count) SystemParametersInfo 20, 0, path & pic(i), &H1 End Sub




Reply With Quote