Logging in Windows Event Log in Unmanaged C++ - windows

I know that I can use ReportEvent method to write event logs in windows. But it seems to me that this method is useful for logging events prior to Windows Vista and 7 event log changes. For example, I don't think I can create a custom application log, set sessionID, ... using this library.
My other option will be using the System::Diagnostics methods like WriteEntry. This one has the features that I'm looking for, but the problem is that I can only use it in /clr mode.
My question is: is there any unmanaged C++ library for logging events to Windows 7?
Cheers,
Reza++

Thanks #Luke, the answer is ETW. For writting to event logger, you can not use the legacy API and you should use the manifest-based providers.

Related

How to monitor and record Win API calls made by executable files for certain action?

PowerBuilder application has some limitations on how objects are managed in libraries. for example there is no way i can copy user object from one library to another through script.
I am looking for some way to monitor the PowerBuilder application and record sequence of system events performed in library painter. Based on recorded events i want to have a list of win32 API calls that were made for those actions. And in the end reproduce same results with win32 API calls i recorded.
The Purpose is to bypass use of PowerBuilder IDE for library functions.
Please tell me how is that possible?
Ver: PB 12.5 / Win 7, 8.1
You can use ORCA functionality to update the library files from an external application. Look at the PDF file under the SDK\ORCA folder. There is a function PBORCA_LibraryEntryCopy.
It would be helpful if you told us what version of PowerBuilder you are using. Also more detail on why. What is it that you want to accomplish? There could be a simpler method that you didn't think of if we knew exactly what and why.

How to watch new processes that are running or terminated in Visual C++

I wonder how to watch new processes that are running or terminated. Can I do it with Windows 7 APIs? How?
I'm using Visual C++ in Windows 7 and don't want to use .Net Framework.
Whilst you can do this using polling (i.e. EnumProcesses), the best way to do it is an event driven approach. And to do that you need to use WMI. This MSDN page gives sample code.
Update Apparently you can use Event Tracing for Windows as an alternative, but I personally know nothing about that.
You may use Process32First and Process32Next from Tool Help library. This MSDN article has an example how to obtain the list of running processes.
An alternative is EnumProcesses function.

How can I call Windows API functions using emacs lisp?

I want to call some Windows API functions to manipulate Windows Input Method Editor to make my Emacs an IME-aware application. How can I call Windows API functions using Emacs lisp?
Thank you!
I dont believe its possible to directly call native code from emacs; the best you'll be able to achieve is to proxy calls to the Windows API through another process, and communicate with it through IPC
Check this stackoverflow question:
load a dynamic library from elisp
I think maybe need a proxy interface, but use w32-send-sys-command can do little things,
code 61776 can send hotkey maybe worth a try

newbie question on win32 app log

I am new in in Visual Studio Win32 (C++) Applications
In java where I work, logging is easy using log4j for instance.
How is the logging done in a Win32 app?
I have seen some code using macros to write to files.
Am I responsible to create some logging mechanism?
Is there a standard way to log in win32?
Thanks
Use the Event Log API to write to Windows Event Log
http://msdn.microsoft.com/en-us/library/aa385772(v=vs.85).aspx
Another way is using log4net since you have experience of log4j, there are very similar.
"Windows application" doesn't mean much of anything, Java apps can also run on Windows. There's log4net to adding logging to a .NET application. Log4cxx to do so for an app written in C++. Exact same approach as log4j. The project's home page is here.
It depends on who is going to be using your software's logging facility:
The Windows Event Log API is best if you are writing a service or "system" type task that needs to be supported by an IT support department. Support tools for Windows support remote access of system event logs to create system health alerts and so on.
Other than that, Windows does not have a convenient Logging API. So you need to roll-your own if the system event log is inappropriate.
For developers / debugging purposes theres OutputDebugString that will emit text to your debuggers "Output" window.
It is convenient when writing GUI apps, to make the debug build a console application, so that a console window is displayed in addition to the GUI. printf() can display messages to the console.
Otherwise, some OSS projects I built on windows did include a variant of log4c that had been ported to windows. So log4c can be coerced into working on windows if you really need it.

CONNECTED event not firing in TAPI 3.x

I am working on a TAPI application. While googleing I found a nice post http://www.codeproject.com/KB/IP/devangpro.aspx. But the problem is, I am not getting all the events triggered while making a call. I am able to get INPROGRESS and DISCONNECTD but no CONNECTED event is getting fired (even in the screenshot provided with the article, only "dialing" and "disconnected" values are present, so I am assuming even the author had the same problem).
In my case whole program logic is based on the CONNECTED and DISCONNECTED events.
Please help me to solve the issue.
Also, I am using a CISCO ATA box for obtaining dial tone. I tried with a FAX/DATA as well as FAX/DATA/VOICE modems.
As far as I can see from the code sample, it uses the TAPI3.dll by automatically creating an Interop wrapper through VS.Net. But the use of TAPI3 from managed code is not supported by Microsoft. See this KB article:
Because of the complexity of the TAPI 3.x Component Object Model (COM) interface, the managed wrapper that is created by Microsoft Visual Studio .NET does not work. Therefore, you cannot call TAPI functionality from managed code.
Microsoft has no current plans to release a TAPI interoperative component.
You will have to use a wrapper around TAPI 3.x to use it in managed code. For this, you could for example use JulMar's ITAPI3 wrapper.

Resources