Delphi启动外部程序
无论是用VC还是用Delphi,启动外部程序,
调用的都是相同的系统中的API函数,如下Delphi代码所示:
//登录按钮 procedure TForm1.Label_LoginClick(Sender: TObject); begin RunOtherApp('C:\1.exe'); //启动1.exe end; //Delphi启动其它程序函数 //参数appPath为要打开的程序的路径 procedure TForm1.RunOtherApp(appPath:String); begin //使用WinExec也可以打开程序,这里不用 //WinExec(Pchar(appPath),sw_normal); //使用ShellExecute必须引用ShellAPI.pas单元:uses ShellAPI; ShellExecute(0,'open',Pchar(appPath),nil,nil,SW_SHOWNORMAL); //ShellExecute原型如下 //HINSTANCE ShellExecute( // HWND hwnd, // LPCTSTR lpVerb, // LPCTSTR lpFile, // LPCTSTR lpParameters, //LPCTSTR lpDirectory, // INT nShowCmd //); end; ////////////////////////////////////////////////////////////
![](http://r.qzone.qq.com/cgi-bin/cgi_get_user_pic?openid=00000000000000000000000005492D01&pic=1.jpg&key=14c00103d64a28b46e3a7211892ffbee)
探索代码的奥秘,享受技术的乐趣-_-!...