ralph
8/21/2010 5:19:00 PM
On Sat, 21 Aug 2010 10:43:28 -0400, "Nobody" <nobody@nobody.com>
wrote:
>"Mayayana" <mayayana@invalid.nospam> wrote in message
>news:i4ogsj$njl$1@news.eternal-september.org...
>> I've seen you mention this function before.
>> I just looked up both, but I don't get it.
>> What's the advantage/reason for using
>> OutputDebugString rather than Debug.Print?
>> Likewise, what's the advantage of DebugView
>> over the Immediate window?
>
>If you have subclassing code that crashes the IDE when you stop it, then you
>have to compile it, but Debug.Print output won't show up.
>
>Note that when Debug.Print is compiled into an EXE, the call is not removed,
>but the result is discarded. If you have a statement like:
>
>Debug.Print "LicenseKeyVerify: UserName = " & UserName
>
>Then anyone can view your EXE with a Hex editor, or trace where the call is
>in the disassembly, and break the licensing scheme if it's shareware.
>
>However, Debug.Assert is removed from the EXE, so don't add code that take
>action like a function call. You can test this be compiling the following:
>
>Option Explicit
>
>Private Sub Form_Load()
> Debug.Print MsgBox("Hello from Debug.Print")
> Debug.Assert vbOK = MsgBox("Hello from Debug.Assert vbOK")
> Debug.Assert vbYes = MsgBox("Hello from Debug.Assert vbYes")
>End Sub
>
>When I run this in the IDE using VB6, I get all three MsgBoxes, but the IDE
>breaks at the last Debug.Assert because the result is False. When I run this
>in an EXE, I only see the first MsgBox.
>
Well, might as well add DebugBreak to the pile.
Private Declare Sub DebugBreak Lib "kernel32" Alias "DebugBreak" ()
This replaces VBs "Debug.Assert False" to trigger an outside debugger.