
determining if VB application is running in development mode
Quote:
> Hi, how can I tell if a VB application/DLL is currently only being run in
> the development environment or stand-alone?
While the other ways will show you if you are in the IDE *FROM* the ide, the
following code can be used internally to the program to tell you if you are
running VB at the same time as your program. It checks the task list for VB5 or
VB6. This sort of code is most often used to check for registered versions of
code in a compiled run. What most people want to do is check to to see if their
control is registered ONLY when not running in the IDE(ie only show the annoying
boxes if the person decides to compile and distribute the program).
here goes...(BTW this is 32 bit only code, ie vb5 and vb6)
Add it to a new module, and call it like so
if DevelopmentEnvironment(myForm.hWnd) then
'working in IDE
else
'running standalone
endif
===cut===
Option Explicit
Declare Function apiGetModuleFileName Lib "kernel32" Alias _
"GetModuleFileNameA" (ByVal hModule As Long, ByVal _
lpFileName As String, ByVal nSize As Long) As Long
Declare Function apiGetWindowWord Lib "user32" Alias _
"GetWindowWord" (ByVal hwnd As Long, ByVal nIndex As _
Long) As Integer
Global Const GWW_HINSTANCE = (-6)
Function DevelopmentEnvironment(my_hwnd As Long) As Boolean
Dim ModuleName As String
Dim FileName As String
Dim hInst, ret As Integer
ModuleName = String$(128, Chr$(0))
' Get the hInstance application:
hInst = apiGetWindowWord(my_hwnd, GWW_HINSTANCE)
' Get the ModuleFileName:
' Enter the following two lines as one, single line:
ModuleName = Left$(ModuleName, apiGetModuleFileName(hInst, ModuleName,
Len(ModuleName)))
If (Len(ModuleName)) > 0 Then
' Get the "." in the file name. Then go back three characters.
' FileName should = \VB.EXE, so check for the backslash (\)
' because FileName could be GVB.EXE, which isn't the
' VB executable name:
FileName = Mid$(ModuleName, InStr(ModuleName, ".") - 4)
If FileName = "\VB6.EXE" Or FileName = "\VB5.EXE" Then
DevelopmentEnvironment = True
Else
DevelopmentEnvironment = False
End If
End If
End Function
===cut===
--
----------------------------------------------------------------------------
| Jeff Goslin - MCSD,MCP | "Oh Bentson, you are so mercifully free from the |
----------------------------------------------------------------------------
| how come everyone elses religion is a cult but your cult is a religion |
----------------------------------------------------------------------------
| XGenetic, the ActiveX Artificial Intelligence Genetic Algorithm |
| http://www.winsite.com/info/pc/win95/demo/xgen-sw.zip/ |
----------------------------------------------------------------------------