You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
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 --
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
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).]
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).]
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-
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.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment