ThaiPBL.com

PowerBuilder Library Thailand

อีเมล พิมพ์ PDF

ฟังก์ชั่นสำหรับ PB8, Win2000 นะครับ สำหรับ เวอร์ชั่นอื่นนี่ไม่ได้ทดสอบครับ

ฟังก์ชั่นนี้สำหรับ PB8, Win2000 นะครับ สำหรับ เวอร์ชั่นอื่นนี่ไม่ได้ทดสอบครับ:
ทำการกำหนด global external functions:(ตัวเล็กตัวใหญ่มีผลนะครับ)

function ulong CreateMutexA (ulong lpMutexAttributes, boolean bInitialOwner, ref string lpName) library "kernel32.dll" function ulong GetLastError () library "kernel32.dll" function ulong CloseHandle(ulong hMutex) library "kernel32.dll"

string ls_Name

uint lui_rc2

boolean lb_inherit

// Determine if this application is already running. If so, HALT this instance. lb_inherit=false ls_Name="YourApp" g_mutex_handle=CreateMutexA(0, lb_inherit, ls_Name)

lui_rc2=getlasterror()

// If mutex already exists, this application is already running, so close

if lui_rc2=183 then

CloseHandle(g_mutex_handle)

// MessageBox("Your App Name Here", "This application is already running. You " +& // "cannot start it again") HALT end if

ลองใช้งานดูนะครับ ไปเจอเข้าน่ะครับ เหมาะสำหรับการป้องกันการ รัน application ซ้ำซ้อนในเครื่องเดียวกันน่ะครับ

บทความนี้มาจาก www.soopawat.com