I found a sample code from MSDN which triggers notepad.exe on user logon,
but as i'm trying to compile the program using g++ task.cpp -o task.exe -lole32 -loleaut32 -luuid
in this code block
ILogonTrigger *pLogonTrigger = NULL;
hr = pTrigger->QueryInterface(
IID_ILogonTrigger, (void**) &pLogonTrigger );
pTrigger->Release();
if( FAILED(hr) )
{
printf("\nQueryInterface call failed for ILogonTrigger: %x", hr );
pRootFolder->Release();
pTask->Release();
CoUninitialize();
return 1;
}
It says ILogonTrigger
and IID_ILogonTrigger
is not defined. I checked my header file and tried to swap with the once i got from other compilers, it got even worse. How to code it so that I can get the same user logon trigger ?
The err:
task.cpp:208:5: error: 'ILogonTrigger' was not declared in this scope
208 | ILogonTrigger *pLogonTrigger = NULL;
| ^~~~~~~~~~~~~
task.cpp:208:20: error: 'pLogonTrigger' was not declared in this scope; did you mean 'pTrigger'?
208 | ILogonTrigger *pLogonTrigger = NULL;
| ^~~~~~~~~~~~~
| pTrigger
task.cpp:210:13: error: 'IID_ILogonTrigger' was not declared in this scope; did you mean 'IID_ITaskTrigger'?
210 | IID_ILogonTrigger, (void**) &pLogonTrigger );
| ^~~~~~~~~~~~~~~~~
| IID_ITaskTrigger
this is my header file if it can help solve the problem.