Declare Function FW% Lib "user" Alias "FindWindow" (ByVal lpClassName As Any, ByVal lpCaption As Any)
Declare Function SW% Lib "User" Alias "ShowWindow" (ByVal Handle As Integer, ByVal Cmd As Integer)
Declare Function SF% Lib "User" Alias "SetFocus" (ByVal Handle As Integer)
Declare Function GPPS% Lib "Kernel" Alias "GetPrivateProfileString" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String)
Declare Function GPS% Lib "Kernel" Alias "GetProfileString" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer)
Declare Function WPPS% Lib "Kernel" Alias "WritePrivateProfileString" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lplFileName As String)
Declare Function WPS% Lib "Kernel" Alias "WriteProfileString" (ByVal lpAppName As String, ByVal lpKeyName As String, ByVal lpString As Any)
Declare Function GWPlc% Lib "User" Alias "GetWindowPlacement" (ByVal hWnd As Integer, lpwndpl As WINDOWPLACEMENT)
Declare Function SWPlc% Lib "User" Alias "SetWindowPlacement" (ByVal hWnd As Integer, lpwndpl As WINDOWPLACEMENT)
Declare Function Sound1% Lib "mmsystem" Alias "sndPlaySound" (ByVal lpSoundName As String, ByVal Flags As Integer)
Declare Function Sound0% Lib "mmsystem" Alias "sndPlaySound" (ByVal lpSoundName As Any, ByVal Flags As Integer)
' NOTE: Does not return if duplicate found !!
'
Sub ExitIfAlreadyRunning ()
Dim Title$, Handle%, junk%
' Get App title
Title$ = App.Title
' Set it to something unlikely ...
App.Title = "TestingForDuplicate"
' Search for another app with my title
Handle% = FW(0&, Title$)
' Set my App's title back to what it was
App.Title = Title$
' If another copy was found ...
If Handle% <> 0 Then
' Handle% will probably point to App, so we
' need to give the App the focus to find it's
' Main Window ...
junk% = SF(Handle%)
' ... Get the window ...
Handle% = GAW()
' ... and restore it if possible
If Handle% <> 0 Then
junk% = SW(Handle%, SW_RESTORE)
' Now exit myself and it's done !
End
End If
End If
End Sub
' Sets a window to be floating or non-floating
' Pass form, true for floating, false for not
' returns true if successful, otherwise false
Function FormFloat (FloatForm As Form, Floating%) As Integer
Function GetPrivateProfileString (ByVal ApplicationName As String, KeyName As String, default As String, Size As Integer, FileName As String) As String