Thread: How to monitor process creation?

  1. #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.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981

  3. #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)

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You'll have to be more specific if you want help your compiling problems.

    gg

  5. #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?

  6. #6
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    #include <windows.h>?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #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

  8. #8
    Registered User
    Join Date
    Mar 2008
    Posts
    26
    Maybe I should Create another type of project?

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    No. Just missing headers.
    Well, it's not full source code, is it? Anyway.
    #include <objbase.h>?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #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!

  11. #11
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    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.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #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

  13. #13
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Add

    #define _WIN32_WINNT 0x400

    To your header and

    using namespace std;

    to your source file.
    See if that helps.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #14
    Registered User
    Join Date
    Mar 2008
    Posts
    26
    using namespace std; this one I already have.

    #define _WIN32_WINNT 0x400; didn't help

  15. #15
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You need to have _WIN32_WINNT defined before you include any header files.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

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