on 8/30/02 11:58 AM, Carnivore devoured H.M. van Staveren at
hmvs at xs4all dot nl's message:
>> Oi! Feeling dense. :-P Switch the name of the function we're importing to
>> be before Lib "user32"
>>
> Thanks that did help. No Errors during compiling but Windows said in did
> not recognise SetSystemParametersInfo. After somemore googling i found
> that the function is rally SystemParametersInfo. But windows didn't like
> that
> either. So i found that this function is an alias for
> SystemParametersInfoA.
> Now i have no more runtime errors but am still unable to change the
> wallpaper
> Here's my code:
>
> #If TargetWin32
> Declare Function SystemParametersInfoA Lib "user32" (action as
> integer, param1 as integer, param2 as Ptr, updateUserProfile as integer)
> as boolean
> Dim SPI_SETDESKWALLPAPER As integer
> Dim wallpaper As Memoryblock
> Dim paperPath As String
> Dim f As FolderItem
>
> f=GetOpenFolderItem("image/jpeg")
> If f<>Nil then
> paperPath=f.absolutePath
> wallpaper = NewMemoryBlock(len(paperPath)+4)
> wallpaper.StringValue(0,len(paperPath)) = paperPath
> SPI_SETDESKWALLPAPER = 20
> if not SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, wallpaper, 0)
> then
> MsgBox "error setting wallpaper"
> end if
> End if
> #Endif
>
> Any ideas?
Good point, I always forget that M$ redefines all their API for A (ANSI) or
W (Wide chars)... Sorry about that. Your code looks right to me..there are
only a few suggestions for places to try.. Try putting in 0x0002 for the
updateUserProfile parameter.. that should tell Windows to update it's ini
file. Also, the API spec says to just pass in the name, doesn't say
location. I seem to recall a long time ago that your wallpaper could only
be in the Windows directory. :: shrugs :: worth a shot to move the
wallpaper into the Windows directory and just use it's name, tho I can't
imagine that being a problem. After you make this function call, I would
try hitting the F5 key, it causes Windows to refresh, and your wallpaper may
show up!
~Aaron
--
"You tried your best and you failed miserably. The lesson is 'never try'."
|