|
-
Dec 4th, 2000, 03:56 PM
#1
Thread Starter
Member
If i am using both the Win.ini and registry to boot an application, how can i make it so that only one instance of the application will run?
Essentially i want it to check if the app is already open, if so unload itself, if not continue to load itself.
Can i set this to happen on splash screen ini?
Any help would be appreciated.
-
Dec 4th, 2000, 04:03 PM
#2
Monday Morning Lunatic
Code:
If App.PrevInstance Then
Unload Me
End If
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Dec 4th, 2000, 04:13 PM
#3
Thread Starter
Member
Thankyou for that.
Works a treat.
Regards
M.
-
Dec 4th, 2000, 07:46 PM
#4
Lively Member
here is one step further
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName$, ByVal lpWindowName$) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd&, ByVal nCmdShow&) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd&) As Long
Private Const SW_RESTORE = 9
Public Sub Main()
Dim sTitle$
Dim lRetVal&, hwnd&
If App.PrevInstance Then 'only allows 1 instance of app to be open at a time
sTitle = mdiMain.Caption
App.Title = "newcopy"
mdiMain.Caption = "newcopy"
hwnd = FindWindow(vbNullString, sTitle)
If hwnd <> 0 Then
lRetVal = ShowWindow(hwnd, SW_RESTORE)
lRetVal = SetForegroundWindow(hwnd)
End If
End
Else
mdiMain.Show
End If
End Sub
Don't go away mad, just go away.
Bam-Bam
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|