use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
use constant CLSID_ACTIVEDESKTOP => '{75048700-EF1F-11D0-9888-006097DEACF9}';
my $actdesktop = Win32::OLE->new(CLSID_ACTIVEDESKTOP) or die();
$actdesktop->SetWallpaper('C:\WINNT\winnt256.bmp');
####
C:\>"C:\Documents and Settings\blm\Desktop\test1212.pl"
Win32::OLE(0.1501) error 0x80004002: "No such interface supported" at C:\Documen
ts and Settings\blm\Desktop\test1212.pl line 8
eval {...} called at C:\Documents and Settings\blm\Desktop\test1212.pl l
ine 8
Died at C:\Documents and Settings\blm\Desktop\test1212.pl line 8.
C:\>
####
STDMETHODIMP CMyDesktop::SetWallpaper(BSTR bstrPath)
{
HRESULT hr;
IActiveDesktop *pActiveDesktop;
CoInitialize(NULL);
//Create an instance of the Active Desktop
hr = CoCreateInstance(CLSID_ActiveDesktop, NULL, CLSCTX_INPROC_SERVER,
IID_IActiveDesktop, (void**)&pActiveDesktop);
hr = pActiveDesktop->SetWallpaper(bstrPath, 0);
if (hr != S_OK) {
goto error;
}
hr = pActiveDesktop->ApplyChanges(AD_APPLY_ALL);
pActiveDesktop->Release();
return S_OK;
error:
return hr;
}
####
use strict;
use warnings;
use Win32::OLE;
use Win32::OLE::Variant;
my $adtest = Win32::OLE->new('damnit.MyDesktop') or die();
$adtest->SetWallpaper('C:\WINNT\winnt256.bmp');