C Board  

Go Back   C Board > Platform Specific Boards > Windows Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-15-2008, 11:51 AM   #1
Registered User
 
Join Date: Mar 2008
Posts: 26
Question How to monitor process creation?

I need my program (vc++) to monitor and log applications executions (name and full path to the exe).

My programs runs ar background and if any application on the windows xp system is executed (Microsoft Word, IE, calculator and etc) it should log and it's executable file's path.

I've found this article : http://www.codeproject.com/KB/system...protector.aspx
But it's to complicated and has stuff that I don't need.

I'll appreciate any help.
markiz is offline   Reply With Quote
Old 03-15-2008, 12:09 PM   #2
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
WMI is another way to monitor this:
C++: http://msdn2.microsoft.com/en-us/lib...25(vs.85).aspx
VBScript: http://msdn2.microsoft.com/en-us/lib...11(VS.85).aspx

gg
Codeplug is online now   Reply With Quote
Old 03-15-2008, 01:17 PM   #3
Registered User
 
Join Date: Mar 2008
Posts: 26
Thanks,
But I have problems compiling the code from the example, though I didn't change anything.

(Environment: Visual studio 2005, Visual C++ win32 console application)
markiz is offline   Reply With Quote
Old 03-15-2008, 01:23 PM   #4
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
You'll have to be more specific if you want help your compiling problems.

gg
Codeplug is online now   Reply With Quote
Old 03-15-2008, 01:51 PM   #5
Registered User
 
Join Date: Mar 2008
Posts: 26
At first it complained about "stdafx.h" , so I included it.
Now it complains about:
Error 1 error C2065: 'HRESULT' : undeclared identifier

strange, cause example should have all includes, shouldn't it?
markiz is offline   Reply With Quote
Old 03-15-2008, 02:19 PM   #6
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
#include <windows.h>?
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 03-15-2008, 02:31 PM   #7
Registered User
 
Join Date: Mar 2008
Posts: 26
Quote:
Originally Posted by Elysia View Post
#include <windows.h>?
Why it wasn't included in the example?

Now I have other "include" errors:
Error 1 error C2065: 'COINIT_MULTITHREADED' : undeclared identifier
markiz is offline   Reply With Quote
Old 03-15-2008, 02:32 PM   #8
Registered User
 
Join Date: Mar 2008
Posts: 26
Maybe I should Create another type of project?
markiz is offline   Reply With Quote
Old 03-15-2008, 02:34 PM   #9
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
No. Just missing headers.
Well, it's not full source code, is it? Anyway.
#include <objbase.h>?
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 03-15-2008, 02:39 PM   #10
Registered User
 
Join Date: Mar 2008
Posts: 26
Quote:
Originally Posted by Elysia View Post
No. Just missing headers.
Well, it's not full source code, is it? Anyway.
#include <objbase.h>?
I thought it's a full source.


<objbase.h> didn't help! still same error.

P.s. total count 46 errors!
markiz is offline   Reply With Quote
Old 03-15-2008, 02:48 PM   #11
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
Yes, I see it's a fat example now, but Microsoft didn't include the right headers in the code. Bah. Stupid Microsoft.
What other errors? HRESULT you can get from Windows.h and COM stuff from objbase.h.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 03-15-2008, 02:57 PM   #12
Registered User
 
Join Date: Mar 2008
Posts: 26
I still get COINIT_MULTITHREADED error! Though I've included:
#include <windows.h>
#include <objbase.h>

Maybe, if it's not to hard, you can compile it yourself?


other errors:
Error 1 error C2065: 'COINIT_MULTITHREADED' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 12
Error 2 error C3861: 'CoInitializeEx': identifier not found d:\1\eventsink\eventsink\event.cpp 12
Error 3 error C2065: 'cout' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 15
Error 4 error C2065: 'hex' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 16
Error 5 error C2065: 'endl' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 16
Error 6 error C2065: 'EOAC_NONE' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 35
Error 7 error C3861: 'CoInitializeSecurity': identifier not found d:\1\eventsink\eventsink\event.cpp 27
Error 8 error C2065: 'IWbemLocator' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 51
Error 9 error C2065: 'pLoc' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 51
Error 10 error C2065: 'CLSID_WbemLocator' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 54
Error 11 error C2065: 'IID_IWbemLocator' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 57
Error 12 error C2065: 'IWbemServices' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 71
Error 13 error C2065: 'pSvc' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 71
Error 14 error C2227: left of '->ConnectServer' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 75
Error 15 error C3861: '_bstr_t': identifier not found d:\1\eventsink\eventsink\event.cpp 76
Error 16 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 90
Error 17 error C3861: 'CoSetProxyBlanket': identifier not found d:\1\eventsink\eventsink\event.cpp 101
Error 18 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 116
Error 19 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 117
Error 20 error C2065: 'IUnsecuredApartment' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 126
Error 21 error C2065: 'pUnsecApp' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 126
Error 22 error C2065: 'CLSID_UnsecuredApartment' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 128
Error 23 error C2065: 'IID_IUnsecuredApartment' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 129
Error 24 error C2065: 'EventSink' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 132
Error 25 error C2065: 'pSink' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 132
Error 26 error C2061: syntax error : identifier 'EventSink' d:\1\eventsink\eventsink\event.cpp 132
Error 27 error C2227: left of '->AddRef' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 133
Error 28 error C2227: left of '->CreateObjectStub' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 136
Error 29 error C2065: 'IWbemObjectSink' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 138
Error 30 error C2065: 'pStubSink' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 138
Error 31 error C2065: 'IID_IWbemObjectSink' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 139
Error 32 error C2227: left of '->ExecNotificationQueryAsync' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 144
Error 33 error C2065: 'WBEM_FLAG_SEND_STATUS' : undeclared identifier d:\1\eventsink\eventsink\event.cpp 149
Error 34 error C3861: '_bstr_t': identifier not found d:\1\eventsink\eventsink\event.cpp 145
Error 35 error C3861: '_bstr_t': identifier not found d:\1\eventsink\eventsink\event.cpp 146
Error 36 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 158
Error 37 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 159
Error 38 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 160
Error 39 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 162
Error 40 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 163
Error 41 error C2227: left of '->CancelAsyncCall' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 171
Error 42 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 176
Error 43 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 177
Error 44 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 178
Error 45 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 180
Error 46 error C2227: left of '->Release' must point to class/struct/union/generic type d:\1\eventsink\eventsink\event.cpp 181
markiz is offline   Reply With Quote
Old 03-15-2008, 03:00 PM   #13
Mysterious C++ User
 
Join Date: Oct 2007
Posts: 14,099
Add

#define _WIN32_WINNT 0x400

To your header and

using namespace std;

to your source file.
See if that helps.
__________________
Using: Microsoft Windows™ 7 Professional (x64), Microsoft Visual Studio™ 2008 Team System
I dedicated my life to helping others. This is only a small sample of what they said:
"Thanks Elysia. You're a programming master! How the hell do you know every thing?"
Quoted... at least once.
Quote:
Originally Posted by cpjust
If C++ is 2 steps forward from C, then I'd say Java is 1 step forward and 2 steps back.
Elysia is offline   Reply With Quote
Old 03-15-2008, 03:20 PM   #14
Registered User
 
Join Date: Mar 2008
Posts: 26
using namespace std; this one I already have.

#define _WIN32_WINNT 0x400; didn't help
markiz is offline   Reply With Quote
Old 03-15-2008, 03:29 PM   #15
Registered User
 
Codeplug's Avatar
 
Join Date: Mar 2003
Posts: 3,844
You need to have _WIN32_WINNT defined before you include any header files.

gg
Codeplug is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding creation of destruction and creation of data types yougene C Programming 2 12-16-2008 02:43 PM
File creation date (in windows 98 and XP) esbo C Programming 12 05-03-2006 05:27 PM
program not working...please look at this JOlszewski C Programming 3 01-30-2006 10:33 PM
Dynamic Creation of an object axr0284 Windows Programming 3 02-05-2005 10:27 AM
Newton + Einstein were wrong! Jez A Brief History of Cprogramming.com 64 12-14-2004 02:24 PM


All times are GMT -6. The time now is 09:37 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22