Hallo Sergey Alexandrovich,
First at all thank you for your comment.
After some more researchs on the web, I have found a way to get my trace messages such as I wanted.
I am now using the kernel32.dll to create DBWIN_Buffer and DBWIN_DATA events and to capture the traces massages of other applications.
The method CreateEvent of kernel32 longs for a name. So I can pass the words "DBWIN_BUFFER_READY" and "DBWIN_DATA_READY" to create two events. Defaultly it sets a "local" behind the two words, so the method interptrets it as "Local\DBWIN_BUFFER_READY", when i change it to "Global\DBWIN_BUFFER_READY" I´m getting the possibility to capture the traces of an service.
Here is a link which help me a lot. Maybe you wanna look at it.
http://unixwiz.net/techtips/outputdebugstring.html
Still thank you for your comment. It was the way I wanted to go if I would not find an other possibility. :)
Here is the main block of my code:
p_brEvent = CreateEvent(ref sa, false, true, "Global\\DBWIN_BUFFER_READY");
if (p_brEvent == IntPtr.Zero)
{
throw new CreateEventException("Failed to create event (DBWIN_BUFFER_READY)");
}
p_drEvent = CreateEvent(ref sa, false, false, "Global\\DBWIN_DATA_READY");
if (p_drEvent == IntPtr.Zero)
{
throw new CreateEventException("Failed to create event DBWIN_DATA_READY");
}
p_sfEvent = CreateFileMapping(new IntPtr(-1), ref sa, PageProtection.ReadWrite, 0, 4096, "Global\\DBWIN_BUFFER");
if (p_sfEvent == IntPtr.Zero)
{
throw new CreateEventException("Failed to create a file mapping to slot DBWIN_BUFFER");
}
map_shEvent = MapViewOfFile(p_sfEvent, SECTION_MAP_READ, 0, 0, 512);
if (map_shEvent == IntPtr.Zero)
{
throw new CreateEventException("Failed to create a file mapping to slot DBWIN_BUFFER");
}