線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:737
推到 Plurk!
推到 Facebook!

Starting your application with parameters.

 
axsoft
版主


發表:681
回覆:1056
積分:969
註冊:2002-03-13

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-03-31 13:25:15 IP:61.218.xxx.xxx 未訂閱

Starting your application with parameters.

http://www.hobbypages.net/snip9.html -------------------------------------------------------------------------------- You can send your application parameters and act on them in the main form's OnCreate event. Here's how: --------------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender) 
{ 
 for (int i=0;i<=paramcount();i  ) 
 { 
   if (LowerCase(ParamStr(i))="=" "-x") /*do something special here*/ 
   if (LowerCase(ParamStr(i))="=" "-y") /*do something different here*/ 
   if (LowerCase(ParamStr(i))="=" "-z") /*do something extra specially different, etc.*/ 
 } 
//Other OnCreate events 
}     
-------------------------------------------------------------------------------- I can still start my app without parameters, it just ignores all that code. Or the commandline for my app might be Myapp.exe -x. In this example, -x -y -z are the parameter codes you write in. They don't have to be case sensitive, I just happen to make mine that way. They can even be file names you want to open. The key is that ParamStr() and ParamCount()functions are defined for you in system.hpp, so you can use them. Note: ParamStr(0) returns the path and file name of the executing program. Useful in your AboutDlg... Label5->Caption = "Path to program " ParamStr(0); 聯盟----Visita網站http://www.vista.org.tw ---[ 發問前請先找找舊文章 ]---
系統時間:2024-05-04 18:37:58
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!