How to Determine the Number of VB Applications Running at OnceID: Q84836
|
To determine the total number of Microsoft Visual Basic for Windows applications running at any given time, you can use the Microsoft Windows API functions GetModuleHandle and GetModuleUsage.
The following code fragment demonstrates a technique to find the total
number of Visual Basic for Windows applications currently executing by
determining the number of instances of the Visual Basic run-time module
(VBRUN100.DLL) with the Windows API functions GetModuleHandle and
GetModuleUsage. Remember that Visual Basic for Windows itself is not
counted; only applications created with Visual Basic for Windows are
included.
Declare Function GetModuleUsage% Lib "kernel" (ByVal hModule%)
Declare Function GetModuleHandle% Lib "kernel" (ByVal FileName$)
Sub Command1_Click ()
msg$ = "Number of executing VB Apps: "
hModule% = GetModuleHandle("VBRUN300.DLL")
' For Visual Basic versions 1.0 and 2.0 for Windows, use
' VBRun100.DLL and VBRun2.00.DLL respectively.
nInstances% = GetModuleUsage(hModule%)
msg$ = msg$ + Str$(nInstances%)
MsgBox msg$
End Sub
Additional query words: 2.00 3.00
Keywords :
Version :
Platform :
Issue type :
Last Reviewed: June 11, 1999