Re[2]: 2重起動


[コメントツリー表示を見る] [発言時刻順表示を見る]

Posted by Uz on 1999/11/30 00:34:35

In Reply to: Re: 2重起動 Posted by Uz on 1999/11/30 00:29:44


    ついでなので全部答えます。(^^;

    '以下
    Option Explicit

    Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long
    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
    Private Const SW_RESTORE = 9

    Private Const APP_CAPTION = "UzApplication"

    Private Sub Form_Load()
    Dim nRet As Long

    Me.Caption = "DUMMY_CAPTION"
    If App.PrevInstance = -1 Then
    'Call MsgBox("このアプリケーションは既に起動されています。", vbInformation, "二重起動防止 サンプルプログラム")
    nRet = FindWindow(vbNullString, APP_CAPTION)
    Call SetForegroundWindow(nRet)
    Call ShowWindow(nRet, SW_RESTORE)
    End
    End If
    Me.Caption = APP_CAPTION
    End Sub
    '以上


記事スレッド一覧