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

C / C++ / MFC

 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Rajesh R Subramanian27-Jul-09 23:58
professionalRajesh R Subramanian27-Jul-09 23:58 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Madhu_Rani28-Jul-09 0:07
Madhu_Rani28-Jul-09 0:07 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Manas Bhardwaj28-Jul-09 3:17
professionalManas Bhardwaj28-Jul-09 3:17 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Manas Bhardwaj28-Jul-09 3:25
professionalManas Bhardwaj28-Jul-09 3:25 
GeneralRe: How to access a remote machine from a local machine and perform basic function like execute and close the remote machine's application. Pin
Rajesh R Subramanian28-Jul-09 3:57
professionalRajesh R Subramanian28-Jul-09 3:57 
QuestionConnecting to WMI -using COM [modified] Pin
Member 432083115-Jul-09 22:12
Member 432083115-Jul-09 22:12 
AnswerRe: Connecting to WMI -using COM Pin
Stuart Dootson15-Jul-09 22:24
professionalStuart Dootson15-Jul-09 22:24 
GeneralRe: Connecting to WMI -using COM Pin
Member 432083116-Jul-09 1:59
Member 432083116-Jul-09 1:59 
Well I've initialized it as COINIT_MULTITHREADED in CoInitializeEx() but it doesn't work as hoped. I use the same IWbemServices pointer (all initializations done just the first time) to run an ExecNotificationQuery with different WMI queries. However my ExecNotificationQuery fails. The two queries work fine if done individually but I can't seem to be able register for two separate WMI events separately.

If I do the whole initialization again for my 2nd query then I get an error in COM security initialization.

Code Snippet:
HANDLE hres;
hres = CoInitializeEx(0, COINIT_MULTITHREADED);
if (FAILED(hres))
{output something}
hres = CoInitializeSecurity(NULL,1,NULL,NULL, RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE,NULL, EOAC_NONE,NULL);
hres = CoCreateInstance(
CLSID_WbemLocator,
0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID *) &pLoc);
hres = pLoc->ConnectServer(
_bstr_t(L"ROOT\\WMI"), // Object path of WMI namespace
NULL, // User name. NULL = current user
NULL, // User password. NULL = current
0, // Locale. NULL indicates current
NULL, // Security flags.
0, // Authority (e.g. Kerberos)
0, // Context object
&pSvc // pointer to IWbemServices proxy
);
hres = CoSetProxyBlanket(
pSvc, // Indicates the proxy to set
RPC_C_AUTHN_WINNT, // RPC_C_AUTHN_xxx
RPC_C_AUTHZ_NONE, // RPC_C_AUTHZ_xxx
NULL, // Server principal name
RPC_C_AUTHN_LEVEL_CALL, // RPC_C_AUTHN_LEVEL_xxx
RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
NULL, // client identity
EOAC_NONE // proxy capabilities
);

IEnumWbemClassObject* pEnumerator = NULL;
hres = pSvc->ExecNotificationQuery(
bstr_t("WQL"),
bstr_t("SELECT * FROM ..."),
WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY,
NULL,
&pEnumerator);
Then I use pEnumerator->Next within a loop and cleanup.

I run this function twice in separate threads.Ideas?
QuestionIP from socket handle Pin
sunny_vc15-Jul-09 21:17
sunny_vc15-Jul-09 21:17 
AnswerRe: IP from socket handle Pin
CPallini15-Jul-09 21:28
mveCPallini15-Jul-09 21:28 
QuestionCreateProcess doesn’t passes command line arguments [modified] Pin
staticv15-Jul-09 20:56
staticv15-Jul-09 20:56 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
Franck Paquier15-Jul-09 21:18
Franck Paquier15-Jul-09 21:18 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
Michael Schubert15-Jul-09 22:17
Michael Schubert15-Jul-09 22:17 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
Stuart Dootson15-Jul-09 22:20
professionalStuart Dootson15-Jul-09 22:20 
AnswerRe: CreateProcess doesn’t passes command line arguments Pin
tns_ranjith15-Jul-09 22:41
tns_ranjith15-Jul-09 22:41 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
Michael Schubert15-Jul-09 23:00
Michael Schubert15-Jul-09 23:00 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
Rajesh R Subramanian15-Jul-09 23:45
professionalRajesh R Subramanian15-Jul-09 23:45 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
Michael Schubert15-Jul-09 23:48
Michael Schubert15-Jul-09 23:48 
GeneralRe: CreateProcess doesn’t passes command line arguments Pin
tns_ranjith16-Jul-09 0:11
tns_ranjith16-Jul-09 0:11 
QuestionHow to test is the given path is a directory or a file? Pin
Chesnokov Yuriy15-Jul-09 20:56
professionalChesnokov Yuriy15-Jul-09 20:56 
AnswerRe: How to test is the given path is a directory or a file? Pin
Randor 15-Jul-09 21:08
professional Randor 15-Jul-09 21:08 
AnswerRe: How to test is the given path is a directory or a file? Pin
Chesnokov Yuriy15-Jul-09 22:50
professionalChesnokov Yuriy15-Jul-09 22:50 
AnswerRe: How to test is the given path is a directory or a file? [modified] Pin
CPallini15-Jul-09 21:21
mveCPallini15-Jul-09 21:21 
GeneralRe: How to test is the given path is a directory or a file? Pin
Randor 15-Jul-09 21:38
professional Randor 15-Jul-09 21:38 
GeneralRe: How to test is the given path is a directory or a file? Pin
CPallini15-Jul-09 21:43
mveCPallini15-Jul-09 21:43 

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.