Click here to Skip to main content
15,903,750 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery23-Oct-08 15:31
Mark Salsbery23-Oct-08 15:31 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery23-Oct-08 15:37
Mark Salsbery23-Oct-08 15:37 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape23-Oct-08 16:55
Supriya Tonape23-Oct-08 16:55 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape23-Oct-08 17:04
Supriya Tonape23-Oct-08 17:04 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery23-Oct-08 20:06
Mark Salsbery23-Oct-08 20:06 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape23-Oct-08 20:45
Supriya Tonape23-Oct-08 20:45 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery23-Oct-08 20:49
Mark Salsbery23-Oct-08 20:49 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape23-Oct-08 21:19
Supriya Tonape23-Oct-08 21:19 
It returns S_FALSE at line "HRESULT hr1 = pEnumerator1->Next(WBEM_INFINITE, 1, &pclsObj1, &uReturn1);"

which is in last. I really donno if I doing right things... plz have a look,,


int WMIScannerModule::GetRemoteLoggedOnUsers(IWbemServices *pSvc,pWMIScanParams pScanParams)
{
HRESULT hres = WBEM_S_NO_ERROR;
IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM Win32_LogonSession WHERE LogonType = 2 OR LogonType = 10"),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);

if (FAILED(hres))
{
pSvc->Release();
return WBEM_S_FALSE; // Program has failed.
}

IWbemClassObject *pclsObj;
ULONG uReturn = 0;

while (pEnumerator)
{
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);

if(0 == uReturn)
{
ErrorInfo(hres,11);
break;
}

VARIANT vtProp;
VariantClear(&vtProp);

// Get the value of the Name property
hr = pclsObj->Get(_bstr_t(L"LogonId"), 0, &vtProp, 0, 0);
printf("Logon ID : %s",vtProp.bstrVal);

wstring wstrQuery = L"Associators of {Win32_LogonSession.LogonId=";
wstrQuery += vtProp.bstrVal;
wstrQuery += L"} Where AssocClass=Win32_LoggedOnUser Role=Dependent";

IEnumWbemClassObject* pEnumerator1 = NULL;
hres = pSvc->ExecQuery(
bstr_t("WQL"),
bstr_t(wstrQuery.c_str()),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator1);

IWbemClassObject *pclsObj1;
ULONG uReturn1 = 0;

HRESULT hr1 = pEnumerator1->Next(WBEM_INFINITE, 1, &pclsObj1, &uReturn1);
if(0 == uReturn1)
{
ErrorInfo(hres,11);
break;
}

VARIANT vtProp1;
hr1 = pclsObj->Get(_bstr_t(L"Win32_LogonSession.Name"), 0, &vtProp1, 0, 0);
printf("User Name : %s",vtProp1.bstrVal);
}

return 0;
}

GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery24-Oct-08 4:57
Mark Salsbery24-Oct-08 4:57 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape24-Oct-08 5:51
Supriya Tonape24-Oct-08 5:51 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery24-Oct-08 6:09
Mark Salsbery24-Oct-08 6:09 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape24-Oct-08 6:35
Supriya Tonape24-Oct-08 6:35 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery24-Oct-08 6:36
Mark Salsbery24-Oct-08 6:36 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape24-Oct-08 6:38
Supriya Tonape24-Oct-08 6:38 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery24-Oct-08 6:39
Mark Salsbery24-Oct-08 6:39 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape24-Oct-08 6:41
Supriya Tonape24-Oct-08 6:41 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery24-Oct-08 7:30
Mark Salsbery24-Oct-08 7:30 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape25-Oct-08 12:39
Supriya Tonape25-Oct-08 12:39 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery25-Oct-08 13:04
Mark Salsbery25-Oct-08 13:04 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape25-Oct-08 13:52
Supriya Tonape25-Oct-08 13:52 
GeneralRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape29-Oct-08 13:12
Supriya Tonape29-Oct-08 13:12 
GeneralRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
etaig15-Jun-10 22:33
etaig15-Jun-10 22:33 
QuestionHow to use CompletionPort to exchange data between two threads Pin
Electronic7522-Oct-08 9:38
Electronic7522-Oct-08 9:38 
AnswerRe: How to use CompletionPort to exchange data between two threads Pin
Roger Stoltz22-Oct-08 22:19
Roger Stoltz22-Oct-08 22:19 
Question[Message Deleted] Pin
Member 284578422-Oct-08 7:32
Member 284578422-Oct-08 7:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.