SystemParametersInfo set wallpaper issues

This is a discussion on SystemParametersInfo set wallpaper issues within the Windows Programming forums, part of the Platform Specific Boards category; The third parameter of SystemParametersInfo is supposed to be a null terminated string containing the path to a file to ...

  1. #1
    A10
    A10 is offline
    Registered User
    Join Date
    Nov 2006
    Posts
    85

    Question SystemParametersInfo set wallpaper issues

    The third parameter of SystemParametersInfo is supposed to be a null terminated string containing the path to a file to set as the desktop background.

    If I wanted to just set it as the null background then this works:
    Code:
    SystemParametersInfo
    	(
    	 SPI_SETDESKWALLPAPER,
    	 0,
    	 "",
    	 SPIF_SENDCHANGE
    	);

    But when I try to set the background to a file this doesn't work. GetLastError returns ERROR_FILE_NOT_FOUND even though that's the correct path to the file.

    Code:
    SystemParametersInfo
    	(
    	 SPI_SETDESKWALLPAPER,
    	 0,
    	 "H:\nn.bmp",
    	 SPIF_SENDCHANGE
    	);
    Even stranger when I try calling and outputting SystemParametersInfo with SPI_GETDESKWALLPAPER I get a jumbled string that looks something like 78BB5654 (so it's random looking but it's the same every time).

    How can I set the desktop wallpaper? Am I formatting the path wrong?

  2. #2
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,059
    Possibly?

    Code:
    SystemParametersInfo
    	(
    	 SPI_SETDESKWALLPAPER,
    	 0,
    	 "H:\\nn.bmp",
    	 SPIF_UPDATEINIFILE | SPIF_SENDCHANGE
    	);
    Notice the double back slashes in the file path. The SPIF_UPDATEINIFILE is used to update the stored setting.

  3. #3
    A10
    A10 is offline
    Registered User
    Join Date
    Nov 2006
    Posts
    85

    Question

    Quote Originally Posted by BobS0327 View Post
    Notice the double back slashes in the file path. The SPIF_UPDATEINIFILE is used to update the stored setting.
    Nope still getting file not found. I even moved the file to drive C:\ to see if Windows had problems with taking the file from a flash drive. I even created a shortcut to the picture file and used the target of the shortcut to make sure I had the path right. Still file not found.

    Here's a url on msdn about systemParametersInfo:

    http://msdn.microsoft.com/library/de...metersinfo.asp

  4. #4
    Registered User
    Join Date
    Dec 2006
    Location
    Scranton, Pa
    Posts
    252
    Try ignoring the path altogether, just list the bmp name itself and place both the program and the image inside the same directory.

  5. #5
    A10
    A10 is offline
    Registered User
    Join Date
    Nov 2006
    Posts
    85

    Question

    Quote Originally Posted by Oldman47 View Post
    Try ignoring the path altogether, just list the bmp name itself and place both the program and the image inside the same directory.
    Still file not found. Now there's even more strangeness. Using "" as the path is now returning ERROR_FILE_NOT_FOUND (error code 2) and isn't going to a null background immediately. I have to update the background by dragging a window over the entire thing.

    Here's the code currently:
    Code:
    	SystemParametersInfo
    	(
    	 SPI_SETDESKWALLPAPER,
    	 0,
    	 "C:\\nn.bmp",
    	 SPIF_SENDCHANGE | SPIF_UPDATEINIFILE
    	);
    	std::cout<<GetLastError();
    No error is returned if I use SETWALLPAPER_DEFAULT as the path but since my current wallpaper is the default it does nothing.

    Also how can I stop vc++ from adding the press any key to continue... line to console programs?

  6. #6
    A10
    A10 is offline
    Registered User
    Join Date
    Nov 2006
    Posts
    85

    Smile

    This code works under dev c++ with mingw but not under VC++:
    Code:
    	SystemParametersInfo
    	(
    	 SPI_SETDESKWALLPAPER,
    	 0, //not used
    	 (void*)"C:\\nn.bmp",
    	 SPIF_SENDCHANGE
    	);
    Well Looks Like I'll be using a different IDE for this project.

    Thanks for all your help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 4
    Last Post: 01-13-2008, 01:14 AM
  2. Replies: 7
    Last Post: 08-19-2007, 08:10 AM
  3. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 10:06 AM
  4. Find all possible subset of a given set
    By Downnin in forum C++ Programming
    Replies: 7
    Last Post: 11-09-2005, 01:03 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21