SimpsoN_Bart Posted July 7, 2013 Share Posted July 7, 2013 (edited) Geliştirdiğiniz projelerinize koyabileceğiniz, kendim için geliştirdiğim bir fonksiyon. Programınızdan iki tane açılmasını önler eğer açıksa size sorar. Mutex çalışma prensibine benzer bir yapısı bulunmaktadır. #RequireAdmin $Form1 = GUICreate("Form1", 318, 190) GUISetState(@SW_SHOW) _SK_ProcessCheck('TNCTR', $Form1) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 Exit EndSwitch WEnd Func _SK_ProcessCheck($UNIQUENAME, $PROGRAMNAME, $CONFIRM = 7) DllCall('kernel32.dll', 'int', 'CreateSemaphore', 'int', 0, 'long', 1, 'long', 1, 'str', $UNIQUENAME) Local $GETLASTERROR = DllCall('kernel32.dll', 'int', 'GetLastError'), $ERROR_ALREADY_EXISTS = 183 If $GETLASTERROR[0] = $ERROR_ALREADY_EXISTS And $CONFIRM = 7 Then $CONFIRM = MsgBox(16 + 4, $PROGRAMNAME, 'Bu programın bir örneği zaten çalışıyor! Yeni bir örneğini daha açmak ister misiniz?','',$PROGRAMNAME) If $CONFIRM = 6 Then Return Else Exit EndIf AutoItWinSetTitle($PROGRAMNAME) WinActivate($PROGRAMNAME) EndIf EndFunc ;==>_SK_ProcessCheck() https://www.box.com/s/qymb7inswlhlurpze7kn Ayrıca Bkz: http://www.tnctr.com/topic/204059-singleton-v2/ MSDN Kaynağı: http://msdn.microsoft.com/en-us/library/aa911525.aspx http://msdn.microsoft.com/en-us/library/windows/desktop/ms682438(v=vs.85).aspx Kolay Gelsin.. Edited July 7, 2013 by SimpsoN_Bart Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.