 |
VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.
|
上一篇主題 :: 下一篇主題 |
發表人 |
內容 |
lcm
註冊時間: 2004-12-27 文章: 45
第 1 樓
|
發表於: 星期日 九月 11, 2005 3:00 pm 文章主題: 請問如何使程式無法重覆執行 |
|
|
請問各位大大,
要如何判斷程式已在執行不可重覆執行該程式,謝謝。 |
|
回頂端 |
|
 |
lcm
註冊時間: 2004-12-27 文章: 45
第 2 樓
|
發表於: 星期日 九月 11, 2005 3:17 pm 文章主題: |
|
|
我已在http://fox.hanyu.com.tw/View.aspx?fbId=1&Id=10092中找到了,謝謝。
回復:如何避免vfp做的應用程式的重覆執行呢?
*****************************
* 防止重複運行
*****************************
PROCEDURE ReEntry
PARAMETERS lcTitle
DECLARE integer FindWindow IN win32api string,string
IF FindWindow(0,lcTitle)<>0
CLEAR DLLS
RETURN .t.
ELSE
CLEAR dlls
RETURN .f.
ENDIF
=>檢查title |
|
回頂端 |
|
 |
garfield Site Admin

註冊時間: 2003-01-30 文章: 2160
第 3 樓
|
|
回頂端 |
|
 |
popolon
註冊時間: 2003-09-20 文章: 9
第 4 樓
|
發表於: 星期六 十月 01, 2005 7:48 pm 文章主題: |
|
|
**取得登入CLIENT端電腦之使用者名稱
IF ALLTRIM(SUBSTR(SYS(0),RAT("#",SYS(0))+2)) > "1" AND !EMPTY(ALLTRIM(SUBSTR(SYS(0),RAT("#",SYS(0))+2)))
GcUserName = ALLTRIM(SUBSTR(SYS(0),RAT("#",SYS(0))+2))
ELSE
=Messagebox('主機系統錯誤,請重新登入或重新開機!',0+48,'錯誤訊息')
ENDIF
****
上述程式可取得登入CLIENT端電腦之使用者名稱(登入window的使用者)
再將此使用者名稱記錄在任一處(資料表,登入檔...都可以)
當程式執行時查看紀錄是否存在
若存在則出現訊息視窗
切記
系統結束時記得要把該紀錄清除喔 |
|
回頂端 |
|
 |
KKKLYNN
註冊時間: 2004-09-17 文章: 357
第 5 樓
|
|
回頂端 |
|
 |
sheuok
註冊時間: 2004-11-20 文章: 63 來自: Taiwan
第 6 樓
|
發表於: 星期日 十二月 02, 2007 12:05 pm 文章主題: |
|
|
程式寫法如下:
if uf_已執行("執行檔檔名")>1
Messagebox("程式已經執行!”)
Quit
Endif
****
Function uf_已執行(ulp_執行檔名)
Private All Like m_*
Declare Integer CreateToolhelp32Snapshot In kernel32 Integer dwFlags, Integer th32ProcessID
Declare Integer Process32First In kernel32 Integer hsnapshot, String @ Processentry32
Declare Integer Process32Next In kernel32 Integer hsnapshot, String @ Processentry32
Declare Integer CloseHandle In Kernel32.Dll Integer
ulp_執行檔名=Upper(Juststem(Iif(Empty(ulp_執行檔名),Program(0),ulp_執行檔名)))
m_hsnap=createtoolhelp32snapshot(2,0) &&取得 m_hsnap
m_proc=num2dword(296)+Repl(Chr(0),292)
m_first=process32first(m_hsnap,@m_proc)
m_open=0
Do While m_first#0
m_file=Substr(m_proc,37,260)
m_file=Upper(Juststem(Left(m_file, At(Chr(0),m_file)-1))) &&取得執行檔名稱(不含附加名)
m_open=m_open+Iif(Alltrim(m_file)==Alltrim(ulp_執行檔名),1,0)
m_first=process32next(m_hsnap,@m_proc)
Enddo
closehandle(m_hsnap)
Return m_open
Endfunc
Function num2dword(lp_值)
Private All Like m_*
m_b3=Int(lp_值/256^3)
m_b2=Int((lp_值 - m_b3*256^3)/256^2)
m_b1=Int((lp_值 - m_b3*256^3 - m_b2*256^2)/256)
m_b0=Mod(lp_值, 256)
Return Chr(m_b0)+Chr(m_b1)+Chr(m_b2)+Chr(m_b3)
Endfunc |
|
回頂端 |
|
 |
|
|
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
|
|