N
Nikos 'paranic' Parastatidis
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
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