home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / MSGTRACE.ZIP / MyProjects / MsgTrace / MsgTracerLib / MsgTracerLib.cpp next >
Encoding:
C/C++ Source or Header  |  1998-05-30  |  2.6 KB  |  106 lines

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File        : MsgTracerLib.cpp
  4. // Project     : MsgTrace
  5. // Component   : MsgTracerLib
  6. //---------------------------------------------------------------------------
  7. // Description : implementation of interfaces to MsgTracerLib.dll
  8. //
  9. /////////////////////////////////////////////////////////////////////////////
  10. //
  11. // SourceSafe Strings. Do not change.
  12. //---------------------------------------------------------------------------
  13. // $Author: jeskes $
  14. // $Date : $
  15. // $Revision : $
  16. //
  17. /////////////////////////////////////////////////////////////////////////////
  18.  
  19. #include <stdio.h> 
  20. #include <stdarg.h>
  21.  
  22. #include "MsgTracer.h"
  23. #include "MsgTracer_i.c"
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26.  
  27. extern "C" void MsgTracerAttachProcess( DWORD dwProcessId, BOOL bWait )
  28. {
  29.     IMsgTracerComp* tracer;
  30.  
  31.     HRESULT hr = CoCreateInstance( CLSID_MsgTracerComp,
  32.                                    NULL,
  33.                                    CLSCTX_ALL,
  34.                                    IID_IMsgTracerComp,
  35.                                    (void**) &tracer );
  36.  
  37.     if( SUCCEEDED( hr ) )
  38.     {
  39.         hr = tracer->AttachProcess( dwProcessId, bWait );
  40.         tracer->Release();
  41.     }
  42. }
  43.  
  44. /////////////////////////////////////////////////////////////////////////////
  45.  
  46. extern "C" void MsgTracerAttachCurrentProcess( BOOL bWait )
  47. {
  48.     MsgTracerAttachProcess( GetCurrentProcessId(), bWait );
  49. }
  50.  
  51. /////////////////////////////////////////////////////////////////////////////
  52. // Diagnostics output
  53. /////////////////////////////////////////////////////////////////////////////
  54.  
  55. extern "C" void MsgTracerWriteA( LPCSTR lpszMessage )
  56. {
  57.     OutputDebugStringA( lpszMessage );
  58. }
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61.  
  62. extern "C" void MsgTracerWriteW( LPCWSTR lpszMessage )
  63. {
  64.     OutputDebugStringW( lpszMessage );
  65. }
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68.  
  69. extern "C" void __cdecl MsgTracerPrintfA( LPCSTR lpszFormat, ... )
  70. {
  71.     va_list args;
  72.     va_start( args, lpszFormat );
  73.  
  74.     int nBuf;
  75.     char szBuffer[ 2048 ];
  76.  
  77.     nBuf = _vsnprintf(szBuffer, sizeof( szBuffer ), lpszFormat, args );
  78.  
  79.     if( nBuf >= 0 )
  80.     {
  81.         OutputDebugStringA( szBuffer );
  82.     }
  83.  
  84.     va_end(args);
  85. }
  86.  
  87. /////////////////////////////////////////////////////////////////////////////
  88.  
  89. extern "C" void __cdecl MsgTracerPrintfW( LPCWSTR lpszFormat, ... )
  90. {
  91.     va_list args;
  92.     va_start( args, lpszFormat );
  93.  
  94.     int nBuf;
  95.     wchar_t szBuffer[ 2048 ];
  96.  
  97.     nBuf = _vsnwprintf( szBuffer, sizeof( szBuffer ) / sizeof( wchar_t ), lpszFormat, args );
  98.     
  99.     if( nBuf >= 0 )
  100.     {
  101.         OutputDebugStringW( szBuffer );
  102.     }
  103.  
  104.     va_end(args);
  105. }
  106.