冰楓論壇

標題: 如何限定此程式只可以開一次 [打印本頁]

作者: 0720    時間: 2018-6-11 19:03
提示: 作者被禁止或刪除 內容自動屏蔽
作者: boindary    時間: 2018-6-11 19:07
判斷程序吧??
作者: 0720    時間: 2018-6-15 09:43
提示: 作者被禁止或刪除 內容自動屏蔽
作者: qwe032747    時間: 2018-6-18 22:47
0720 發表於 2018-6-15 09:43
有語法嗎~

Private Declare Function CreateMutex Lib "kernel32" Alias "CreateMutexA" (lpMutexAttributes As SECURITY_ATTRIBUTES, ByVal bInitialOwner As Long, ByVal lpName As String) As Long
Private Type SECURITY_ATTRIBUTES
        nLength As Long
        lpSecurityDescriptor As Long
        bInheritHandle As Long
End Type
Private Const ERROR_ALREADY_EXISTS = 183&
Private Sub Form_Load()
    Dim sa As SECURITY_ATTRIBUTES
    sa.bInheritHandle = 1
    sa.lpSecurityDescriptor = 0
    sa.nLength = Len(sa)
    Call CreateMutex(sa, 1, App.Title)
    If (Err.LastDllError = ERROR_ALREADY_EXISTS) Then
        MsgBox "請勿重復運行", , ""
        End
    End If
End Sub


VB6防多開的寫法




歡迎光臨 冰楓論壇 (https://bingfong.com/) Powered by 冰楓