Announcement

Collapse
No announcement yet.

Problem debugging and using ShellExecute

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

  • Problem debugging and using ShellExecute

    Hi all,

    Anyone have an idea why this does not work when you are in debug mode? It works if complied to an exe and executed normally. I'm using the OS to automate loading of a browser into localhost.
    Code:
    #Compile Exe
    #Dim All
    
    #Include "Win32API.inc"
    
    Function PBMain () As Long
    
        Dim nShellPtr       As Dword
        nShellPtr = ShellExecute(ByVal %NULL, "open", "http://127.0.0.1/" & Chr$(0), ByVal %NULL, ByVal %NULL,%sw_shownormal Or %sw_showmaximized)
    
    End Function
    Thanks in advance.

    Brett
    Last edited by Gary Beene; 12 Jul 2014, 01:00 AM. Reason: Code: tags

  • #2
    Workaround

    To those who are interested, it appears the problem exists with Shell command and function, CreateProcess and all other similar API calls (regardless of async and new process calls). I noticed the compiled exe fights with pbedit.exe while running in debug mode, which indicates that the debugger is trapping API calls before executing them.

    A workaround:
    Code:
    #Compile Exe
    #Dim All
    
    #Include "Win32API.inc"
    
    Macro DEBUG_RUNNING = Environ$("PBDEBUG") <> ""
    
    Function PBMain () As Long
    
        Dim nShellPtr       As Dword
        
        If Not DEBUG_RUNNING Then
            nShellPtr = ShellExecute(ByVal %NULL, "open", "http://127.0.0.1/" , ByVal %NULL, ByVal %NULL,%sw_shownormal)
        End If
    
    End Function
    I now manually load a browser and call localhost when I'm debugging.

    Regards
    Brett
    Last edited by Gary Beene; 12 Jul 2014, 01:01 AM. Reason: Code: tags

    Comment

    Working...
    X