Declare Function ExitWindows% Lib "USER" (ByVal dwReserved&, ByVal wReturnCode%)
'windows system info declares
Declare Function GetDriveType% Lib "KERNEL" (ByVal nDrive%)
'status.dll declares
Declare Function FreeDriveSpace& Lib "status.dll" (ByVal Drive$)
Declare Function FreeMem& Lib "status.dll" ()
Declare Function GetFreeRes% Lib "status.dll" (ByVal ResType%)
'INI declarations
Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer
Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFilename As String) As Integer
'search window list declares
Declare Function GetWindow% Lib "USER" (ByVal hWnd%, ByVal wCmd%)
Global Const GW_HWNDFIRST = 0
Global Const GW_HWNDNEXT = 2
Declare Function GetWindowText Lib "User" (ByVal hWnd As Integer, ByVal lpString As String, ByVal aint As Integer) As Integer
Declare Function FindWindow Lib "User" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
'prev inst restoration declarations
Declare Function ShowWindow Lib "User" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
Global Const SW_RESTORE = 9
Global Const SW_SHOWNORMAL = 1
Declare Function GetClassName Lib "User" (ByVal hWnd As Integer, ByVal lpClassName As String, ByVal nMaxCount As Integer) As Integer
'window placement declarations
Type PointAPI '4 Bytes - Synonymous with LONG
x As Integer
y As Integer
End Type
Type Rect '8 Bytes
Left As Integer
Top As Integer
right As Integer
bottom As Integer
End Type
Type WindowPlacement '22 Bytes
Length As Integer
Flags As Integer
ShowCmd As Integer
ptMinPosition As PointAPI
ptMaxPosition As PointAPI
rcNormalPosition As Rect
End Type
Declare Function GetWindowPlacement% Lib "User" (ByVal hWnd%, lpwndpl As WindowPlacement)
Sub CenterForm (F As Form)
F.Left = (Screen.Width - F.Width) / 2
F.Top = (Screen.Height - F.Height) / 2
End Sub
Function FindPrevInstance% (Cap$)
Dim w%, y%, winCap As String * 255
w% = GetWindow%(Form1.hWnd, GW_HWNDFIRST)
Do While w% <> 0
y% = GetWindowText(w%, winCap, 254)
If Left$(winCap, Len(Cap$)) = Cap$ And w% <> Form1.hWnd Then
'kludge to prevent finding hidden vb parent window