见题,给个例子!shellexceute 怎么用?
解决方案 »
- 關於updatebatch問題
- 如何在有客户端连接的情况下关闭服务端?
- 各位大侠:有没有什么方法通过IP地址和端口号实现远程的ODBC设置?
- websnap的问题,用Web App Debugger指向Default URL,不能打开我的test.
- 程序启动太慢
- 怎样将光标定在,dbgrid的第一行,第一列上
- ADOQuery的问题求解.
- 初学者,求助 sql
- 客户端<->web service<->com+ <->sql问题
- 关于一个编译成可独立执行程序的问题?(可不是一般的小case).
- 我调用QUERY的SQL功能时,出现以下错误
- 一个关于报表的问题,这个过程为啥运行半天还不出结果?高分求答案!!!
//ShellExecute(hWnd: HWND; Operation, FileName, Parameters,
//Directory: PChar; ShowCmd: Integer): ; stdcall;
var
hReadme: HINST;hReadme := ShellExecute(0, 'open', 'notepad', 0, 0, SW_MAXIMIZE);
if hReadme <= 32 then
ShowMessage('fail');
var
hReadme: HINST;
se: SHELLEXECUTEINFO;
hInstallProcess: THandle;
begin
ZeroMemory ( @se, sizeof ( SHELLEXECUTEINFO));
se.cbSize := sizeof(SHELLEXECUTEINFO);
se.fMask := SEE_MASK_NOCLOSEPROCESS;
se.Wnd := 0;
se.lpFile := 'notepad'; //运行的文件。
se.nShow := SW_MAXIMIZE;
se.lpVerb := 'open';
se.lpParameters := nil;
se.lpDirectory := nil;
se.nShow := SW_MAXIMIZE;
se.hProcess := 0;
se.hInstApp := 0; if ShellExecuteEx(@se) = true then
begin
hInstallProcess := se.hProcess;
showmessage(IntToStr(hInstallProcess));
end;
ShellExecuteEx在运行以后可以取出进程ID,可以继续对该程序进行控制啦。
CreateProcess比较麻烦的
MyHandle: THandle;
MyStartupInfo: TStartupInfo;
MyProcessInfo: TProcessInformation;
//hyadd end; //hyadd 为了控制外部报表打印程序
procedure ExecuteApp(MyPath: String);
procedure CloseApp(MyHandle: THandle);
//hyendprocedure ExecuteApp(MyPath: String);
begin
FillChar(MyStartupInfo, SizeOf(MyStartupInfo), 0);
//清除MyStartupInfo中的数据 MyStartupInfo.cb:=SizeOf(MyStartupInfo); CreateProcess(PChar(MyPath), nil, nil, nil, False,
DETACHED_PROCESS, nil, nil, MyStartupInfo,MyProcessInfo); MyHandle:=MyProcessInfo.hProcess;
//把执行的程序的句柄赋值给MyHandle,它会在终止程序时用到
end;procedure CloseApp(MyHandle: THandle);
begin
TerminateProcess(MyHandle, 0);
end;