function WinExecAndWait32(FileName:String; Visibility: Integer): Integer;
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then Result := -1 { pointer to PROCESS_INF } else begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
//GetExitCodeProcess(ProcessInfo.hProcess,Result);
Result := 0;
end;
end;
var
zAppName:array[0..512] of char;
zCurDir:array[0..255] of char;
WorkDir:String;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(zAppName,FileName);
GetDir(0,WorkDir);
StrPCopy(zCurDir,WorkDir);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := Visibility;
if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
false, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name }
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) then Result := -1 { pointer to PROCESS_INF } else begin
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
//GetExitCodeProcess(ProcessInfo.hProcess,Result);
Result := 0;
end;
end;
解决方案 »
- 请问大家一般用Delphi开发网络服务器用TServerSocket还是TIdTCPServer还是...?
- 请问下,我要编写一个程式用于打开文件,应该要写么写代码?
- 放分了,原因:问大S,95,哈欠
- 怎样使 listview 中的每条纪录的名字不能更改
- 一个比较难的问题!关于RxLibrary控件
- 我在ScrollBox中放了一个大的图片,AutoSize 为true,但是scrollbox中还是没有出现滚动条何故??
- 请问怎么做才可以在子类窗体中看到父类窗口中建立的控件呢?
- 我的部分系统现在提供源代码了
- 我现在想知道如果使用完成端口,我需要与数据库连接使用,每个客户是否需要生成一个ADOConnectioin和ADOQuery来对应,不知道可否指示一下。
- 北京-外资企业诚聘赴爱尔兰delphi开发项目经理-北京
- 为什么我得trayicon不消失
- 怎样提取TWebBrowser的头?
是需要引用一个单元,这个单元有所有的API函数,
但我不知道这个单元的文件名。
不过这个函数太麻烦,有没有现成的,直接引用就可以的(这个可不可以直接引用
,是不是API函数)