Change Wallpaper Application

Discussion in 'C++' started by Nikos 'paranic' Parastatidis, Jun 11, 2004.

  1. Hi there group

    im new here and totaly noob at cpp

    i would like to ask how can i complete the folowing code in order to make an
    application to change the wallpaper of a windows xp machine.

    eg. changedesktop.exe c:\images\background.bmp

    also i have to inform you that i have disabled command prompt on the winxp
    machine witch makes me think that i dont need a console application as i see
    from the new project menu on visual studio.net
    the following code uses IActiveDekstop API from microsoft

    http://msdn.microsoft.com/library/d...ence/ifaces/iactivedesktop/iactivedesktop.asp


    long changeWallpaper(char *strPicPath, DWORD flags)
    {
    WCHAR tempstr[MAX_PATH];
    MultiByteToWideChar(CP_ACP, 0, strPicPath, -1, tempstr, sizeof(tempstr) );

    HRESULT hr;
    IActiveDesktop *pActiveDesktop;

    CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_ActiveDesktop, NULL,
    CLSCTX_INPROC_SERVER,IID_IActiveDesktop, (void**)&pActiveDesktop);
    if(hr == S_OK )
    { pActiveDesktop->SetWallpaper(tempstr, 0);
    WALLPAPEROPT wpo;
    wpo.dwSize = sizeof(WALLPAPEROPT);
    wpo.dwStyle = flags;
    pActiveDesktop->SetWallpaperOptions(&wpo,0);
    pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
    pActiveDesktop->Release();
    return TRUE;
    }
    else return FALSE;
    }

    i wonder i someone can complete the rest of the code so i can compile it on
    Visial Studio .NET


    Thanks in advance
    Nikos
    Nikos 'paranic' Parastatidis, Jun 11, 2004
    #1
    1. Advertising

  2. Nikos 'paranic' Parastatidis

    Pete C. Guest

    Nikos 'paranic' Parastatidis wrote:
    > Hi there group
    >
    > im new here and totaly noob at cpp
    >
    > i would like to ask how can i complete the folowing code in order to
    > make an application to change the wallpaper of a windows xp machine.


    Please ask further questions about Windows in a Windows group. Only standard
    C++ is topical here. Nevertheless, this should work:

    #include <windows.h>
    #include <iostream>

    long changeWallpaper(char *strPicPath, DWORD flags)
    {
    WCHAR tempstr[MAX_PATH];
    MultiByteToWideChar(CP_ACP, 0, strPicPath, -1, tempstr, sizeof(tempstr) );

    HRESULT hr;
    IActiveDesktop *pActiveDesktop;

    CoInitialize(NULL);
    hr = CoCreateInstance(CLSID_ActiveDesktop, NULL,
    CLSCTX_INPROC_SERVER,IID_IActiveDesktop, (void**)&pActiveDesktop);
    if(hr == S_OK )
    { pActiveDesktop->SetWallpaper(tempstr, 0);
    WALLPAPEROPT wpo;
    wpo.dwSize = sizeof(WALLPAPEROPT);
    wpo.dwStyle = flags;
    pActiveDesktop->SetWallpaperOptions(&wpo,0);
    pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
    pActiveDesktop->Release();
    return TRUE;
    }
    else return FALSE;
    }

    int main(int argc, char* argv[])
    {
    if(argc == 2)
    {
    if(!changeWallpaper(argv[1], *INSERT CORRECT FLAGS HERE*))
    std::cout << "Error changing wallpaper" << std::endl;
    }
    else
    {
    std::cout << "usage: changewallpaper <image path>" << std::endl;
    }
    return 0;
    }

    You'll need to consult MSDN to find the correct flags to put in.

    - Pete

    >

    <snip>
    >
    >
    > Thanks in advance
    > Nikos
    Pete C., Jun 11, 2004
    #2
    1. Advertising

  3. > Hi there group
    >
    > im new here and totaly noob at cpp
    >
    > i would like to ask how can i complete the folowing code in order to make an
    > application to change the wallpaper of a windows xp machine.
    >
    > eg. changedesktop.exe c:\images\background.bmp
    >
    > also i have to inform you that i have disabled command prompt on the winxp
    > machine witch makes me think that i dont need a console application as i see
    > from the new project menu on visual studio.net
    > the following code uses IActiveDekstop API from microsoft
    >
    > http://msdn.microsoft.com/library/d...ence/ifaces/iactivedesktop/iactivedesktop.asp
    >
    > <code>


    > i wonder i someone can complete the rest of the code so i can compile it on
    > Visial Studio .NET
    >
    >
    > Thanks in advance
    > Nikos


    "wallpaper" ??? "new project menu"??? etc etc Standard C++ has no such things.

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    To iterate is human, to recurse divine.
    -L. Peter Deutsch
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Prateek R Karandikar, Jun 12, 2004
    #3
  4. Nikos 'paranic' Parastatidis

    John Carson Guest

    "Nikos 'paranic' Parastatidis" <> wrote in message
    news:
    > Hi there group
    >
    > im new here and totaly noob at cpp
    >
    > i would like to ask how can i complete the folowing code in order to
    > make an application to change the wallpaper of a windows xp machine.
    >


    For future reference, the following three groups should meet most of your
    VC++/User Interface/Windows Graphics needs:

    microsoft.public.vc.language
    microsoft.public.win32.programmer.ui
    microsoft.public.win32.programmer.gdi

    Numerous other Microsoft groups can be found by connecting direct to the MS
    news server at

    msnews.microsoft.com


    --
    John Carson
    1. To reply to email address, remove donald
    2. Don't reply to email address (post here instead)
    John Carson, Jun 13, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    5
    Views:
    1,081
  2. Terrance N. Phillip

    System Independent Wallpaper Changer

    Terrance N. Phillip, Jul 6, 2005, in forum: Python
    Replies:
    4
    Views:
    475
    Terrance N. Phillip
    Jul 6, 2005
  3. Stewart Berman

    Change Wallpaper In Linux Using Java

    Stewart Berman, Jun 3, 2008, in forum: Java
    Replies:
    0
    Views:
    584
    Stewart Berman
    Jun 3, 2008
  4. Stewart Berman

    Change Wallpaper In Linux Using Java

    Stewart Berman, Jun 3, 2008, in forum: Java
    Replies:
    14
    Views:
    792
    Arne Vajhøj
    Jun 19, 2008
  5. Andrew Valkenburg

    wallpaper

    Andrew Valkenburg, Jan 11, 2004, in forum: Javascript
    Replies:
    2
    Views:
    86
Loading...

Share This Page