Advertisement
7_2009-2012 Debugging and Error Handling #233864

IsDebug - InIDE

return TRUE if inside IDE, return FALSE if in compiled EXE, work in standard EXE and in DLL

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
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
원본 댓글 (3)
Wayback Machine에서 복구됨