执行一个外部程序并等待它的完成
Function WinExecExW(cmd,workdir:pchar;visiable:integer):DWORD;
var
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
FillChar(StartupInfo,SizeOf(StartupInfo),#0);
StartupInfo.cb:=SizeOf(StartupInfo);
StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow:=visiable;
if not CreateProcess(nil,cmd,nil,nil,false,Create_new_console or Normal_priority_class,nil,nil,StartupInfo,ProcessInfo) then
result:=0
else
begin
waitforsingleobject(processinfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess,Result);
end;
end;
Function WinExecExW(cmd,workdir:pchar;visiable:integer):DWORD;
var
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
FillChar(StartupInfo,SizeOf(StartupInfo),#0);
StartupInfo.cb:=SizeOf(StartupInfo);
StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow:=visiable;
if not CreateProcess(nil,cmd,nil,nil,false,Create_new_console or Normal_priority_class,nil,nil,StartupInfo,ProcessInfo) then
result:=0
else
begin
waitforsingleobject(processinfo.hProcess,INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess,Result);
end;
end;
解决方案 »
- 一个烦恼的问题关于exe源码转成dll
- 一个奇怪的控件问题(为什么topendialog打开快捷方式的时候找到的会是EXE文件?也不能返回桌面快捷方式的正确路径?)(答完结贴)
- 恳请赐教,indy tcp文件传输问题
- [在线等]求教random()和Randomize;的用法
- +++++++请问,如何用opengl显示中文字体+++++++++
- ADOQuery异步执行SQL时,DBGrid显示不出数据?
- 在 sql server 中有没自动编号的字段?因为,我一般都是先做 access 然后再转成 sql sever 的。
- 认为自己很牛X的来看看
- 不知如何下手,DELPHI有用么,如何解决?
- 我想知道,我们平时用的计算机..............
- TEdit控件如何实现右对齐的输出
- 消息捕捉
StartupInfo.cb:=SizeOf(StartupInfo);
StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow:=visiable;
可不可以解释一下
//用sizeof(StartupInfo)个#0字符来填充StartupInfo字符串
StartupInfo.cb:=SizeOf(StartupInfo);
//TStartupInfo结构的大小为SizeOf(StartupInfo);
StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
//设置TStartupInfo的标志位,其各个选项的含义如下:
(*
dwFlagsThis is a bit field that determines whether certain STARTUPINFO members are used when the process creates a window. Any combination of the following values can be specified: Value Meaning
STARTF_USESHOWWINDOW If this value is not specified, the wShowWindow member is ignored.
STARTF_USEPOSITION If this value is not specified, the dwX and dwY members are ignored.
STARTF_USESIZE If this value is not specified, the dwXSize and dwYSize members are ignored.
STARTF_USECOUNTCHARS If this value is not specified, the dwXCountChars and dwYCountChars members are ignored.
STARTF_USEFILLATTRIBUTE If this value is not specified, the dwFillAttribute member is ignored.
STARTF_FORCEONFEEDBACK If this value is specified, the cursor is in feedback mode for two seconds after CreateProcess is called. If during those two seconds the process makes the first GUI call, the system gives five more seconds to the process. If during those five seconds the process shows a window, the system gives five more seconds to the process to finish drawing the window.
The system turns the feedback cursor off after the first call to GetMessage, regardless of whether the process is drawing.
For more information on feedback, see the following Res section.
STARTF_FORCEOFFFEEDBACK If specified, the feedback cursor is forced off while the process is starting. The normal cursor is displayed. For more information on feedback, see the following Res section.
STARTF_USESTDHANDLES If this value is specified, sets the standard input of the process, standard output, and standard error handles to the handles specified in the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure. The CreateProcess function's fInheritHandles parameter must be set to TRUE for this to work properly.
If this value is not specified, the hStdInput, hStdOutput, and hStdError members of the STARTUPINFO structure are ignored.*)
StartupInfo.wShowWindow:=visiable;
//这一句容易了,控制这个进程的窗口为可见的!
//这一句容易了,控制这个进程的窗口为可见的!那么visiable的取值又有些什么规定呢?