Results 1 to 24 of 24

Thread: VB - Detect if you are running in the IDE...

Threaded View

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    VB - Detect if you are running in the IDE...

    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, _
    4.                                                                                       ByVal lpFileName As String, _
    5.                                                                                       ByVal nSize As Long) _
    6.                                                                                       As Long
    7. Private Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As Long
    8.  
    9. Private Function InIDE() As Boolean
    10. Dim s As String
    11.  
    12.     s = Space$(255)
    13.    
    14.     Call GetModuleFileName(GetModuleHandle(vbNullString), s, Len(s))
    15.    
    16.     InIDE = (UCase$(Trim$(s)) Like "*VB6.EXE*")
    17.    
    18. End Function
    19.  
    20. 'usage
    21. MsgBox InIDE

    This is for VB6, for versions below 6, change the bolded section to the file name of the VB executable (VB5.exe, etc).
    Last edited by si_the_geek; Sep 27th, 2010 at 08:02 AM. Reason: corrected issue caused by change in code tags
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width