VB icon

IsDebug - InIDE

Email
Submitted on: 2/4/2015 5:38:00 AM
By: Serge Lachapelle (from psc cd)  
Level: Intermediate
User Rating: By 2 Users
Compatibility: VB 5.0, VB 6.0
Views: 1033
 
     return TRUE if inside IDE, return FALSE if in compiled EXE, work in standard EXE and in DLL
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
'**************************************
' Name: IsDebug - InIDE
' Description:return TRUE if inside IDE, return FALSE if in compiled EXE, work in standard EXE and in DLL
' By: Serge Lachapelle (from psc cd)
'**************************************

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


Other 7 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.