IsDebug - InIDE
return TRUE if inside IDE, return FALSE if in compiled EXE, work in standard EXE and in DLL
Original Author: Serge Lachapelle
Code
Private Type MODULEENTRY32
dwSize As Long
th32ModuleID As Long
th32ProcessID As Long
GlblcntUsage As Long
ProccntUsage As Long
modBaseAddr As Long
modBaseSize As Long
hModule As Long
szModule As String * 256
szExePath As String * 260
End Type
Private Const TH32CS_SNAPMODULE = &H8
Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Module32First Lib "kernel32" (ByVal hSnapshot As Long, uProcess As MODULEENTRY32) As Long
Private Declare Function Module32Next Lib "kernel32" (ByVal hSnapshot As Long, uProcess As MODULEENTRY32) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
Public Function IsDebug() As Boolean
Dim qwe As String
Dim hProcess As MODULEENTRY32, hMod&, hSnapshot&
hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId)
hProcess.dwSize = Len(hProcess)
hMod = Module32First(hSnapshot, hProcess)
qwe = Left$(hProcess.szExePath, InStr(hProcess.szExePath, vbNullChar) - 1)
If LCase$(Right$(qwe, 4)) <> ".exe" Then
Do
hMod = Module32Next(hSnapshot, hProcess)
qwe = Left$(hProcess.szExePath, InStr(hProcess.szExePath, vbNullChar) - 1)
Loop Until (LCase$(Right$(qwe, 4)) = ".exe") Or (hMod = 0)
End If
IsDebug = LCase(hProcess.szExePath) Like "*vb#.exe*"
CloseHandle hSnapshot
End Function
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.