Hello! I'm creating a basic program to change my desktop wallpaper via a random seed and SystemParametersInfo() and I'm having some issues. The function appears to execute without error, yet it does not reset my background. Any thoughts?
I have made one interesting observation. Sometimes it will reset the background to black, and other times it will simply keep the previous background. I've also experimented with other formats other than .jpg and that makes no difference.
Yeah I did it manually before and it didn't work. I inserted some code to do it in the program just now, but the same result appears. No wallpaper change!
Is there some other process I'm forgetting about? This box is on Vista SP1.
Excellent, thank you! It certainly works now. And I have a few more things to research. :)
I had no idea you could use SystemParametersInfoA() anymore. The references I found online regarded it as a legacy function which didn't support .jpg's, which I thought to be a little strange.
The MSDN entry for SystemParametersInfo makes not comments about limitations of SystemParametersInfoA. Like all (or at least most) -A functions, it no doubt just converts all strings from ANSI to Unicode and then calls the corresponding -W function.
You could convert your code to work with Unicode literals, wstring, wstringstream (or better, wostringstream), etc. and the -W versions of the functions.
For this application I think I'll just stick to the (PVOID) cast of the c_str() since I'm only developing this for personal use. Though if I do decide to utilize Unicode functions, that's very good to know!
Though one thing does worry me a bit. It appears my linker does not like CoTaskMemFree(pidl), which is a little odd. I have included windows.h, which should also include Objbase.h. Which library would I need to link to in order to utilize this function? I'm currently using Dev-C++ 4.9.9.2.
[Linker error] undefined reference to `CoTaskMemFree@4'
Nope! Though I will once I reinstall Dev-C++. It appears, accessing the project options makes the entire IDE crash now.. interesting. I reinstalled/updated and everything appears to be working fine now.
Thanks anyways! Now to bury my head into some more code..