Announcement

Collapse
No announcement yet.

Success with OutputDebugString()?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Greg Turgeon
    replied
    Code:
    Robert-
       
    You've supplied the missing piece: the BYCOPY.  I had experimented 
    with adding the $CRLF, but by itself it made no difference.  Thanks 
    for your help.
       
    And a quick tryout with the System Internals utility seems to show no 
    trouble using it.

    ------------------
    -- Greg
    [email protected]

    Leave a comment:


  • Semen Matusovski
    replied
    Really works with CRLF. Thanks, Robert.

    ------------------

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Greg,

    You must append a CRLF to the string in order for DebugView/EE
    to display it. This code has worked for me from my DLLs for some
    time now.

    Code:
    ' wrapper for OutputDebugString
    SUB ODS(strMsg AS STRING) EXPORT
       
       LOCAL strDebugMsg AS STRING
       
       strDebugMsg = strMsg & CHR$(13, 10)
       OutputDebugString BYCOPY strDebugMsg
       
    END SUB
    Originally posted by Greg Turgeon:
    Code:
    Semen-- 
       
    Your suggestion is interesting (as usual) and is similar to the 
    approach that I've been using.  However, as you say, "When 
    debugger.exe is in memory it's possible to do approx. so...."  The 
    appealing feature of DBWIN.EXE and similar utilities is that, 
    supposedly, no debugger is required, and a debugging window becomes 
    much simpler to use.
       
    As Microsoft puts it, "If the application has no debugger, the system 
    debugger displays the string. If the application has no debugger and 
    the system debugger is not active, OutputDebugString does nothing."  
    This fits the description of the operation of the System Internals 
    utility: "Simply execute the DebugView/EE program file (dbgview.exe) 
    and DebugView/EE will immediately start capturing debug output."  
       
    This program, not DBWIN, is the one truly I want to use.  It has many 
    capabilities not available through DBWIN.  Have a look.
     [url="http://www.sysinternals.com/dbgview.htm"]http://www.sysinternals.com/dbgview.htm[/url] 
       
    I have the required declaration in SYSTEM.INI (OutputTo=NUL) but have 
    yet to display anything in the debugging window of DBWIN or similar 
    utilities.  Obviously I'm doing something wrong or misunderstand 
    what's required.

    [This message has been edited by Greg Turgeon (edited July 30, 2000).]

    Robert

    ------------------

    Leave a comment:


  • Semen Matusovski
    replied
    Originally posted by Greg Turgeon:
    Obviously I'm doing something wrong or misunderstand
    what's required.
    I am too (Win2000). I saw two messages in log, but they were not from my program.

    To say true, I had troubles with some other sysinternals utilities before.
    They are too clever (at least, for me).
    I was satisfied only with FAT32, which allows to see FAT32 drives under NT4.

    ------------------


    [This message has been edited by Semen Matusovski (edited July 30, 2000).]

    Leave a comment:


  • Greg Turgeon
    replied
    Code:
    Semen-- 
       
    Your suggestion is interesting (as usual) and is similar to the 
    approach that I've been using.  However, as you say, "When 
    debugger.exe is in memory it's possible to do approx. so...."  The 
    appealing feature of DBWIN.EXE and similar utilities is that, 
    supposedly, no debugger is required, and a debugging window becomes 
    much simpler to use.
       
    As Microsoft puts it, "If the application has no debugger, the system 
    debugger displays the string. If the application has no debugger and 
    the system debugger is not active, OutputDebugString does nothing."  
    This fits the description of the operation of the System Internals 
    utility: "Simply execute the DebugView/EE program file (dbgview.exe) 
    and DebugView/EE will immediately start capturing debug output."  
       
    This program, not DBWIN, is the one truly I want to use.  It has many 
    capabilities not available through DBWIN.  Have a look.
     [url="http://www.sysinternals.com/dbgview.htm"]http://www.sysinternals.com/dbgview.htm[/url] 
       
    I have the required declaration in SYSTEM.INI (OutputTo=NUL) but have 
    yet to display anything in the debugging window of DBWIN or similar 
    utilities.  Obviously I'm doing something wrong or misunderstand 
    what's required.

    [This message has been edited by Greg Turgeon (edited July 30, 2000).]

    Leave a comment:


  • Semen Matusovski
    replied
    Greg --
    OutputDebugString works perfect, for example, in PB debugger
    (= Debug Print).
    If you want to have own PB "debugger" much easy to do something like in following "resident" utility.
    Code:
       #Compile Exe "Debugger.Exe"
       #Register None
       #Dim All
       #Include "Win32Api.Inc"
       
       Type COPYDATASTRUCT
           dwData As Dword Ptr
           cbData As Dword
           lpData As Asciiz Ptr
       End Type
    
       CallBack Function DlgProc
          Static lpCdt As COPYDATASTRUCT Ptr, Txt As String, nEl As Long
          Select Case CbMsg
             Case %WM_SIZE
                Dim rc As RECT
                GetClientRect CbHndl, rc
                SetWindowPos GetDlgItem(CbHndl, 101), 0, _
                   0.03 * rc.nRight, 0.02 * rc.nBottom, 0.94 * rc.nRight, _
                   0.96 * rc.nBottom, %SWP_NOACTIVATE Or %SWP_NOZORDER
             Case %WM_COPYDATA
                lpCdt = CbLparam: Incr nEl
                Txt = Format$(nEl, "000000 ") + Time$ + " |    " + @[email protected]
                Control Send CbHndl, 101, %LB_INSERTSTRING, 0, StrPtr(Txt)
                Function = 1: Exit Function
          End Select
    
       End Function
       Function PbMain
          Local hDlg As Long
          Dialog New 0, "Debugger", 0, 0, 200, 100, _
             %WS_SYSMENU Or %WS_CAPTION Or %WS_THICKFRAME, _
             %WS_EX_TOPMOST Or %WS_EX_TOOLWINDOW To hDlg
          Control Add ListBox, hDlg, 101, , 0, 0, 0, 0
          Dialog Show Modal hDlg Call DlgProc
       End Function
    When debugger.exe is in memory it's possible to do approx. so:
    Code:
       #Compile Exe
       #Register None
       #Dim All
       #Include "Win32Api.Inc"
       %Debug = 1
    
       '----------------------------------------
       #If %Debug
       Type COPYDATASTRUCT
          dwData As Dword Ptr
          cbData As Dword
          lpData As Asciiz Ptr
       End Type
    
       Sub DbgOut (Txt As String)
          Static hWndDebug As Long, Cdt As COPYDATASTRUCT
          Do
             If IsWindow(hWndDebug) Then Exit Do
             hWndDebug = FindWindow(ByVal 0&, "Debugger")
             If hWndDebug = 0 Then Exit Sub
          Loop
          Cdt.cbdata = Len(Txt) + 1
          Cdt.lpData  = StrPtr(Txt)
          SendMessage hWndDebug, %WM_COPYDATA, 0, VarPtr(Cdt)
       End Sub
       #EndIf
       '--------------------------------------
       
       CallBack Function DlgProc
          Select Case CbMsg
             Case %WM_INITDIALOG
               Control Add TextBox, CbHndl, 101, "", 10, 10, 80, 12
               Control Add Button, CbHndl, 102, "Button", 30, 30, 40, 12
             Case %WM_COMMAND
               #If %Debug
               DbgOut "WM_COMMAND" + Str$(CbCtl)
               #EndIf
             Case %WM_PAINT
               #If %Debug
               DbgOut "WM_PAINT"
               #EndIf
          End Select
       End Function
    
       Function PbMain
          Dim hDlg As Long
          Dialog New 0, "Test", 200, 200, 100, 50, %WS_CAPTION Or %WS_SYSMENU To hDlg
          Dialog Show Modal hDlg Call DlgProc
       End Function
    ------------------

    Leave a comment:


  • Greg Turgeon
    started a topic Success with OutputDebugString()?

    Success with OutputDebugString()?

    Code:
    Has anyone successfully used OutputDebugString with a PB EXE or DLL?  
    I can find no detailed information about using DBWIN.EXE, and 
    OutputDebugString isn't capture by DBWIN--or by any of the other, 
    similar utilities available.  (A particularly nice one is available 
    at the SysInternals site.)
    ------------------
    -- Greg
    [email protected]
Working...
X