home *** CD-ROM | disk | FTP | other *** search
- /////////////////////////////////////////////////////////////////////////////
- //
- // File : MsgTracerLib.cpp
- // Project : MsgTrace
- // Component : MsgTracerLib
- //---------------------------------------------------------------------------
- // Description : implementation of interfaces to MsgTracerLib.dll
- //
- /////////////////////////////////////////////////////////////////////////////
- //
- // SourceSafe Strings. Do not change.
- //---------------------------------------------------------------------------
- // $Author: jeskes $
- // $Date : $
- // $Revision : $
- //
- /////////////////////////////////////////////////////////////////////////////
-
- #include <stdio.h>
- #include <stdarg.h>
-
- #include "MsgTracer.h"
- #include "MsgTracer_i.c"
-
- /////////////////////////////////////////////////////////////////////////////
-
- extern "C" void MsgTracerAttachProcess( DWORD dwProcessId, BOOL bWait )
- {
- IMsgTracerComp* tracer;
-
- HRESULT hr = CoCreateInstance( CLSID_MsgTracerComp,
- NULL,
- CLSCTX_ALL,
- IID_IMsgTracerComp,
- (void**) &tracer );
-
- if( SUCCEEDED( hr ) )
- {
- hr = tracer->AttachProcess( dwProcessId, bWait );
- tracer->Release();
- }
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- extern "C" void MsgTracerAttachCurrentProcess( BOOL bWait )
- {
- MsgTracerAttachProcess( GetCurrentProcessId(), bWait );
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // Diagnostics output
- /////////////////////////////////////////////////////////////////////////////
-
- extern "C" void MsgTracerWriteA( LPCSTR lpszMessage )
- {
- OutputDebugStringA( lpszMessage );
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- extern "C" void MsgTracerWriteW( LPCWSTR lpszMessage )
- {
- OutputDebugStringW( lpszMessage );
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- extern "C" void __cdecl MsgTracerPrintfA( LPCSTR lpszFormat, ... )
- {
- va_list args;
- va_start( args, lpszFormat );
-
- int nBuf;
- char szBuffer[ 2048 ];
-
- nBuf = _vsnprintf(szBuffer, sizeof( szBuffer ), lpszFormat, args );
-
- if( nBuf >= 0 )
- {
- OutputDebugStringA( szBuffer );
- }
-
- va_end(args);
- }
-
- /////////////////////////////////////////////////////////////////////////////
-
- extern "C" void __cdecl MsgTracerPrintfW( LPCWSTR lpszFormat, ... )
- {
- va_list args;
- va_start( args, lpszFormat );
-
- int nBuf;
- wchar_t szBuffer[ 2048 ];
-
- nBuf = _vsnwprintf( szBuffer, sizeof( szBuffer ) / sizeof( wchar_t ), lpszFormat, args );
-
- if( nBuf >= 0 )
- {
- OutputDebugStringW( szBuffer );
- }
-
- va_end(args);
- }
-