  | 
				VFP 愛用者社區 本討論區為 Visual Foxpro 愛用者經驗交流的地方, 請多多利用"搜尋"的功能, 先查看看有無前例可循, 如果還有不懂的再發問. 部份主題有附加檔案, 須先註冊成為社區居民才可以下載.   
				 | 
			 
		 
		 
	
		| 上一篇主題 :: 下一篇主題   | 
	 
	
	
		| 發表人 | 
		內容 | 
	 
	
		Ruey
 
 
  註冊時間: 2003-03-12 文章: 1698 來自: tunglo
  第 1 樓
  | 
		
			
				 發表於: 星期日 五月 04, 2003 3:37 pm    文章主題: VFP程式不重複執行方法?(轉貼) | 
				     | 
			 
			
				
  | 
			 
			
				1.範例1
 
m.C_NAME=C_NAME      &&公司名稱
 
DECLARE INTEGER FindWindow IN User32.DLL AS Find_window STRING,STRING
 
IF FIND_WINDOW(0,M.c_name) <> 0
 
 N = FIND_WINDOW(0,m.c_name)
 
   = MESSAGEBOX('對不起,本程式已經啟動,請查看任務欄!',48,'提示...系統資源省點用哦……^_^')
 
 RETURN 0
 
ENDIF
 
 
 
2.範例2
 
DECLARE INTEGER FindWindow  IN Win32api STRING, STRING
 
DECLARE LONG BringWindowToTop IN Win32API LONG
 
DECLARE LONG ShowWindow IN Win32API LONG, LONG
 
CTITLE="【 酒 店 管 理 系 統 】"
 
m.LNHWND=FINDWINDOW(0,CTITLE)
 
IF LNHWND<>0
 
   WAIT WINDOW "重 複 提 示 : 程 序 已 經 運 行 !" AT SROWS()/2-3,(SCOL()-LEN(CTITLE))/2 TIMEOUT 2
 
   BRINGWINDOWTOTOP(m.LNHWND)
 
   SHOWWINDOW(m.LNHWND,3)
 
   QUIT
 
ENDIF | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		liangszpt
 
  
  註冊時間: 2004-11-18 文章: 263 來自: な东省深圳市
  第 2 樓
  | 
		
			
				 發表於: 星期三 三月 23, 2005 9:44 am    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				| 对于范例一,我不是很明白怎么做,请各位指教 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		syntech
 
 
  註冊時間: 2003-05-16 文章: 4252 來自: Taipei,Taiwan
  第 3 樓
  | 
		
			
				 發表於: 星期三 三月 23, 2005 10:21 am    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				哪邊不懂,請詳述. _________________ 如果公司有下列困擾:
 
1. 找不到便宜,快速,簡易的 生產排程軟體
 
2. 不知道如何快速排定 採購計劃
 
3. 成本抓不準,自己算比軟體算有用
 
4. 想學習系統規劃,想找系統架構的顧問
 
 
請聯絡我們,也許我們幫得上忙 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		liangszpt
 
  
  註冊時間: 2004-11-18 文章: 263 來自: な东省深圳市
  第 4 樓
  | 
		
			
				 發表於: 星期三 三月 23, 2005 11:07 am    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				
 
 
1.範例1 
 
m.C_NAME=C_NAME &&公司名稱 
 
DECLARE INTEGER FindWindow IN User32.DLL AS Find_window STRING,STRING 
 
IF FIND_WINDOW(0,M.c_name) <> 0 
 
N = FIND_WINDOW(0,m.c_name) 
 
  = MESSAGEBOX('對不起,本程式已經啟動,請查看任務欄!',48,'提示...系統資源省點用哦……^_^') 
 
RETURN 0 
 
ENDIF 
 
 
m.C_Name是什么意思?它的内容要怎么设定?公司名称?刚才我试过,系统还是可以执行多次的。
 
 
 
现在我也遇到一样的问题,我想当系统已经执行后(不退出的情况),如果再执行系统,会有提示说“程式已经启动”. | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		syntech
 
 
  註冊時間: 2003-05-16 文章: 4252 來自: Taipei,Taiwan
  第 5 樓
  | 
		
			
				 發表於: 星期三 三月 23, 2005 5:15 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				c_name 是 "視窗標題" 或"執行檔名稱",不是什麼公司名稱
 
 
msdn 
 
--------------
 
FindWindow Function
 
 
--------------------------------------------------------------------------------
 
 
 
The FindWindow function retrieves a handle to the top-level window whose class name and window name match the specified strings. This function does not search child windows. This function does not perform a case-sensitive search.
 
 
To search child windows, beginning with a specified child window, use the FindWindowEx function.
 
 
 
Syntax
 
 
HWND FindWindow(          LPCTSTR lpClassName,
 
    LPCTSTR lpWindowName
 
);
 
Parameters
 
 
lpClassName
 
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero. 
 
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names. 
 
 
If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter. 
 
 
lpWindowName
 
[in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. 
 
Return Value
 
 
If the function succeeds, the return value is a handle to the window that has the specified class name and window name.
 
 
If the function fails, the return value is NULL. To get extended error information, call GetLastError. _________________ 如果公司有下列困擾:
 
1. 找不到便宜,快速,簡易的 生產排程軟體
 
2. 不知道如何快速排定 採購計劃
 
3. 成本抓不準,自己算比軟體算有用
 
4. 想學習系統規劃,想找系統架構的顧問
 
 
請聯絡我們,也許我們幫得上忙 | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		freehotpc
 
 
  註冊時間: 2005-03-27 文章: 28
 
  第 6 樓
  | 
		
			
				 發表於: 星期日 三月 27, 2005 7:42 pm    文章主題:  | 
				     | 
			 
			
				
  | 
			 
			
				我是这样做的:
 
 
set talk off
 
close all
 
clea all
 
 
if not "VFP"$home()
 
  set defa to Home()
 
endif
 
 
if fcreate("main.tmp")=-1
 
  _Screen.Visible=.f.
 
  =MessageBox("本程序已在使用中!",0+48+0,"重复运行")
 
  on SHUTDOWN
 
  quit
 
endif
 
 
... | 
			 
		  | 
	 
	
		| 回頂端 | 
		 | 
	 
	
		  | 
	 
	
		 | 
	 
 
  
  	 
	    
  	   | 
 	
您 無法 在這個版面發表文章 您 無法 在這個版面回覆文章 您 無法 在這個版面編輯文章 您 無法 在這個版面刪除文章 您 無法 在這個版面進行投票 您 無法 在這個版面附加檔案 您 無法 在這個版面下載檔案
  | 
   
  
		 |