In thread run() function I'm using a disphelper functional.
This function is implementing a request to WMI for monitor a system events:
Code:
try
{
const wchar_t * Query = (const wchar_t *) this-> TriggerRequest.utf16 ();
dhCheck (dhGetObject (L "winmgmts: {impersonationLevel = impersonate, (Security)}! \ \ \ \. \ \ root \ \ cimv2", NULL, & wmiSvc));
dhCheck (dhGetValue (L "% o", & wmiEventSrc, wmiSvc, L ". ExecNotificationQuery (% S)", Query));
emit this-> TriggerState (this-> TriggerName, 1);
while (TRUE)
{
CDispPtr wmiLatestEvent;
dhCheck (dhGetValue (L "% o", & wmiLatestEvent, wmiEventSrc, L ". NextEvent"));
emit this-> Triggered (this-> TriggerName, this-> GenerateTriggerMsg (wmiLatestEvent), this-> TriggerIcon);
wmiLatestEvent.Dispose ();
}
}
catch (string errstr)
{
ErrorMSG
= this
-> GenerateErrorMSG
(QString:: fromStdString (errstr
));
emit this-> TriggerState (this-> TriggerName, -1);
}
try
{
const wchar_t * Query = (const wchar_t *) this-> TriggerRequest.utf16 ();
dhCheck (dhGetObject (L "winmgmts: {impersonationLevel = impersonate, (Security)}! \ \ \ \. \ \ root \ \ cimv2", NULL, & wmiSvc));
dhCheck (dhGetValue (L "% o", & wmiEventSrc, wmiSvc, L ". ExecNotificationQuery (% S)", Query));
emit this-> TriggerState (this-> TriggerName, 1);
while (TRUE)
{
CDispPtr wmiLatestEvent;
dhCheck (dhGetValue (L "% o", & wmiLatestEvent, wmiEventSrc, L ". NextEvent"));
emit this-> Triggered (this-> TriggerName, this-> GenerateTriggerMsg (wmiLatestEvent), this-> TriggerIcon);
wmiLatestEvent.Dispose ();
}
}
catch (string errstr)
{
ErrorMSG = this-> GenerateErrorMSG (QString:: fromStdString (errstr));
emit this-> TriggerState (this-> TriggerName, -1);
}
To copy to clipboard, switch view to plain text mode
problem follows on line
Code:
dhCheck (dhGetObject (L "winmgmts: {impersonationLevel = impersonate, (Security)}! \ \ \ \. \ \ root \ \ cimv2", NULL, & wmiSvc));
dhCheck (dhGetObject (L "winmgmts: {impersonationLevel = impersonate, (Security)}! \ \ \ \. \ \ root \ \ cimv2", NULL, & wmiSvc));
To copy to clipboard, switch view to plain text mode
fails with the message:
Member:
Function: GetObject
Error In: GetObjectEx
Error: Neioaene? Aneay ioeaea
Code: 800401e4
Source: Application "
But before the program fails with the message Runtime error.
And even earlier (and now) in another application, this code (in multiple threads) working perfectly.
also, in class constructor such code works fine without any problems.
Out of the run() function this code works;
What's the problem?
Environment variables, configuration files (*.pro) (except a list of files) are identical to the working and nonworking applications.
Shl.
Help pliz.
3 days of debuging ....
Bookmarks