VB and VBA Users Source Code: Determine if a DLL or EXE is being called from the IDE
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Determine if a DLL or EXE is being called from the IDE
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Wednesday, February 06, 2002
Hits:
907
Category:
Windows API
Article:
The following code will determine if a DLL or EXE is being run from the IDE. Option Explicit Private Declare Function GetModuleFileName Lib "kernel32" Alias "GetModuleFileNameA" (ByVal hModule As Long, ByVal lpFileName As String, ByVal nSize As Long) As Long 'Purpose : Determines if a project or a DLL is being run within the IDE 'Inputs : N/A 'Outputs : Returns True if the project or DLL is being run from the IDE, else returns false 'Author : Andrew Baker (copyright www.vbusers.com) 'Date : 31/Jan/2002 'Notes : 'Revisions : Public Function IDERunning() As Boolean Dim sModuleName As String * 255 Dim lModuleNameLen As Long On Error GoTo ErrHandler 'Get the exe file name lModuleNameLen = GetModuleFileName(App.hInstance, sModuleName, 255) sModuleName = Left$(sModuleName, lModuleNameLen) 'Compare the exe name If UCase$(sModuleName) Like "*\VB[4-6].EXE*" Then IDERunning = True Else IDERunning = False End If Exit Function ErrHandler: Debug.Print "Error in IDERunning: " & Err.Description Debug.Assert False End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder