반응형
// Declare Global External Functions 선언부분
function ulong CreateMutexA (ulong lpMutexAttributes,int bInitialOwner,ref string lpName) library "kernel32.dll"
function ulong GetLastError () library "kernel32.dll"
// 어플리케이션 Open Event 스크립트
ulong ll_mutex, ll_err
string ls_mutex_name
if handle (GetApplication (), false) <> 0 then
ls_mutex_name = this.AppName + char (0)
// Create the mutex. Since we're not going to do anything with
// it, ignore the first two arguments
ll_mutex = CreateMutexA (0, 0, ls_mutex_name)
ll_err = GetLastError ()
if ll_err = 183 then // Is running
MessageBox ("Error", "Application already running.")
halt close
else
// Not running
end if
else
// We're in the development environment.
// If you go ahead and create the mutex here, be sure to destroy it
// in the application close event, or bad things will happen.
end if
찾고보니 간단하구만....-_-;;
DB에 상태값을 넣어두는것은 오류 종료시 문제가 있고,
FindWindowsA로 타이틀명을 가지고 오는것도 조금은 문제가 있는데,
이것이 제일 깔끔한듯....
double.pbl파워빌더 6.5용 샘플소스
function ulong CreateMutexA (ulong lpMutexAttributes,int bInitialOwner,ref string lpName) library "kernel32.dll"
function ulong GetLastError () library "kernel32.dll"
// 어플리케이션 Open Event 스크립트
ulong ll_mutex, ll_err
string ls_mutex_name
if handle (GetApplication (), false) <> 0 then
ls_mutex_name = this.AppName + char (0)
// Create the mutex. Since we're not going to do anything with
// it, ignore the first two arguments
ll_mutex = CreateMutexA (0, 0, ls_mutex_name)
ll_err = GetLastError ()
if ll_err = 183 then // Is running
MessageBox ("Error", "Application already running.")
halt close
else
// Not running
end if
else
// We're in the development environment.
// If you go ahead and create the mutex here, be sure to destroy it
// in the application close event, or bad things will happen.
end if
찾고보니 간단하구만....-_-;;
DB에 상태값을 넣어두는것은 오류 종료시 문제가 있고,
FindWindowsA로 타이틀명을 가지고 오는것도 조금은 문제가 있는데,
이것이 제일 깔끔한듯....

반응형
'자료 iN > 성공 & 강연 ' 카테고리의 다른 글
KBS 경제세미나 - 한국기업 선진화의 길, 박종규 KSS해운 창업자 강연 (0) | 2010.03.18 |
---|---|
wIniNet API - FTP Upload, Download를 위한 VB Script (0) | 2010.03.15 |
KBS 경제세미나 - 200년 영속 기업의 비밀 (0) | 2010.03.11 |
KBS 아침마당 목요특강-20,30대가 알아야할 공병호박사의 성공법칙-10년만 투자하라 (0) | 2010.03.10 |
KBS 경제세미나 - 세계경제위기와 국가 경쟁력, 이희범 회장(stx에너지) (0) | 2010.03.09 |