Thread: changing desktop wallpaper

  1. #1
    Registered User
    Join Date
    Apr 2006
    Posts
    5

    changing desktop wallpaper

    how can i change the desktop wallpaper with a c programm?
    (without active desktop)

    the exambles i found on this page doesn't run.

    thanks for help : )

  2. #2
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Surely there must be a Win32 API call to do this?
    http://msdn.microsoft.com
    http://www.google.co.uk
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  3. #3
    Registered User
    Join Date
    Apr 2006
    Posts
    5
    ähmm, is it possible that some could write a code examble for me , please =)

  4. #4
    Registered User
    Join Date
    Aug 2005
    Posts
    1,267
    there are some examples at www.codeproject.com -- but they require COM and Microsoft IE.

  5. #5
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Code:
    #pragma comment( lib, "user32.lib" ) 
    #include <windows.h>
    
    int WINAPI WinMain (HINSTANCE hInstance,  
        HINSTANCE hPrevInstance,
        LPSTR   lpszCmdLine,
        int     cmdShow     
       )
    {
        SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "c:\\desktop.bmp", SPIF_UPDATEINIFILE);
    
    }

  6. #6
    Registered User
    Join Date
    Feb 2006
    Posts
    20
    well this is what im also looking for but just one question
    if i do this my background doesnt get updated (though the bmp does show up in the desktop configure thingie) , do i need to send a refresh thingie or is the active desktop mocking with me

  7. #7
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Also use SPIF_SENDWININICHANGE

  8. #8
    Registered User
    Join Date
    Feb 2006
    Posts
    20
    ill try thx
    *edit*
    doesnt change anything ; though i see a register change

    here is my testing code (though it is pure c) i didn't want to make a new thread

    Code:
    #pragma comment( lib, "user32.lib" )
    #include <windows.h>
    #include <stdio.h>
    
    int main(int argc,char *argv[])
    {
    	printf("Testing...");
    	scanf("%*c");
    
    	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "c:\\desktop.bmp",SPIF_UPDATEINIFILE);
    	SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "c:\\desktop.bmp",SPIF_SENDWININICHANGE);
    	return 0;
    }
    *edit*
    after googling some more ^^

    Code:
    SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, "c:\\desktop.bmp",SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE );
    bitoperaters are the key here
    thx Tonto for the clue
    Last edited by Narcose; 08-09-2006 at 03:58 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Desktop Wallpaper - Animated Tiff
    By Rune Hunter in forum C# Programming
    Replies: 3
    Last Post: 02-08-2008, 06:59 PM
  2. Getting Icons from the Desktop
    By Mastadex in forum Windows Programming
    Replies: 6
    Last Post: 08-29-2007, 04:33 PM
  3. Changing the desktop wallpaper?
    By Sfpiano in forum Windows Programming
    Replies: 3
    Last Post: 07-10-2005, 07:48 AM
  4. Sticky wallpaper!
    By SMurf in forum Windows Programming
    Replies: 4
    Last Post: 02-21-2003, 12:34 PM
  5. changing the desktop background c++
    By v0id in forum Windows Programming
    Replies: 1
    Last Post: 02-21-2002, 08:03 PM