Click here to Skip to main content
15,920,111 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: How can I display Dlg Message Box? Pin
David Crow22-Oct-08 10:47
David Crow22-Oct-08 10:47 
QuestionGetting NULL value from 'Win32_LogonSession' through WMI [modified] Pin
Supriya Tonape22-Oct-08 9:40
Supriya Tonape22-Oct-08 9:40 
QuestionRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
David Crow22-Oct-08 9:57
David Crow22-Oct-08 9:57 
AnswerRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape22-Oct-08 10:24
Supriya Tonape22-Oct-08 10:24 
QuestionRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
David Crow22-Oct-08 10:35
David Crow22-Oct-08 10:35 
AnswerRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape22-Oct-08 11:23
Supriya Tonape22-Oct-08 11:23 
GeneralRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape22-Oct-08 11:30
Supriya Tonape22-Oct-08 11:30 
GeneralRe: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery22-Oct-08 14:11
Mark Salsbery22-Oct-08 14:11 
General[Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape23-Oct-08 8:40
Supriya Tonape23-Oct-08 8:40 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Mark Salsbery23-Oct-08 9:33
Mark Salsbery23-Oct-08 9:33 
GeneralRe: [Urgent] Re: Getting NULL value from 'Win32_LogonSession' through WMI Pin
Supriya Tonape23-Oct-08 12:44
Supriya Tonape23-Oct-08 12:44 
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 

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.