Click here to Skip to main content
15,904,817 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
my coding..

C#
mParametersInfo(SPI_SETDESKWALLPAPER,1,"C:\\WINDOWS\\Web\\Wallpaper\\Ascent.jpg",0);



i use this API for change the desktop wallpaper.

But it not working.

please seniors can you help me.
Posted
Updated 19-Oct-11 3:06am
v2

1 solution

I think the third parameter should be a wide string.
C++
SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, L"C:\\WINDOWS\\Web\\Wallpaper\\Ascent.jpg", 0);
 
Share this answer
 
Comments
Richard MacCutchan 19-Oct-11 9:42am    
Thanks, just tried this and it works.
@BangIndia 19-Oct-11 10:39am    
sir

It not working sir..
Richard MacCutchan 19-Oct-11 11:35am    
As stated above, I have tried this and it works fine, please show clearly your code that is not working.
@BangIndia 20-Oct-11 1:11am    
#include "stdafx.h"
#include <windows.h>

int main(int argc, char* argv[])
{
SystemParametersInfo(SPI_SETDESKWALLPAPER, 1, L"C:\\WINDOWS\\Web\\Wallpaper\\Ascent.jpg", 0);
return 0;
}

This is my code sir..

it change the wall paper to Blue default.
but not changing to the specified wallpaper..
Niklas L 20-Oct-11 4:51am    
I can only think of three possible reasons for this.
1. There is a typo in the file name/path
2. The jpeg image is using some format extension not supported by default by windows.
3. The program is not authorized to change the wallpaper.

1. Easy to check
2. Does it open in Paint? (Don't use a fancy image program to test if it opens) If it doesn't, try another image to see that the API works. Edit: The correct way to test this is of course to set the wallpaper manually as a .. ehum.. wallpaper.
3. I currently have no solution for this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900