I'm fiddling with COM and as a first program I thought I'd have a fiddle with IActiveDesktop. According to MSDN I need to include shlobj.h, which I do, but this code fails to compile:
Code:
#include <iostream>
#include <windows.h>
#include <shobjidl.h>
#include <shlguid.h>
#include <shlobj.h>
using namespace std;
int main(int argc, char *argv[])
{
HRESULT hr = 0;
IShellLink *pISL;
IActiveDesktop *pIAD;
CoInitialize(0);
hr = CoCreateInstance(CLSID_ShellLink,
NULL, // no aggregation
CLSCTX_INPROC_SERVER,
IID_IShellLink,
(void **) &pISL);
if (SUCCEEDED(hr))
{
pISL->Release();
}
else
{
CoUninitialize();
cout << "Error creating COM object [" << hr << "]" << endl;
return -1;
}
CoUninitialize();
return 0;
}
(I was looking at IShellLink too).
Errors:
Code:
c:\Documents and Settings\lee\Desktop\COMStuff\COMStuff.cpp(12) : error C2065: 'IActiveDesktop' : undeclared identifier
c:\Documents and Settings\lee\Desktop\COMStuff\COMStuff.cpp(12) : error C2065: 'pIAD' : undeclared identifier
Am I missing something here? If I right click IActiveDesktop and "Go to definition" it takes me to shlobj.h so I know it's there.