home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 2130
- ClientLeft = 60
- ClientTop = 345
- ClientWidth = 4620
- LinkTopic = "Form1"
- ScaleHeight = 2130
- ScaleWidth = 4620
- StartUpPosition = 3 'Windows Default
- Begin VB.Label Label1
- Caption = "Only one instance of this program can run."
- Height = 375
- Left = 360
- TabIndex = 0
- Top = 720
- Width = 3615
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- ' ******************************
- ' ******************************
- ' ** MASTERING VB6 **
- ' ** by Evangelos Petroutos **
- ' ** SYBEX, 1998 **
- ' ******************************
- ' ******************************
- Option Explicit
- Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
- (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
- ByVal nCmdShow As Long) As Long
- Const SW_SHOWNORMAL = 1
- Private Sub Form_Load()
- Dim retValue As Long
- Dim otherWnd As Long
- Dim oldCaption As String
- If App.PrevInstance Then
- MsgBox "Cannot start more than one copy."
- Unload Me
-
- otherWnd = FindWindow(0&, oldCaption)
- retValue = ShowWindow(App.hInstance, SW_SHOWNORMAL)
- End If
- End Sub
-