如何让Delphi调用外部程序并等待其运行信息(如结束)
函数一:
view plaincopy to clipboardprint?
uses
Windows,
SysUtils,
Classes,
ShellAPI;
function RunAndWait(FileName: string; Visibility: Integer): THandle;
var
zAppName: array[0..512] of Char;
zCurDir: array[0..255] of Char;
WorkDir: string;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
begin
try
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, nil, nil, false, Create_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then
begin
result := 0;
Exit;
end
else
begin
WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, result);
end;
 
相关文档:
Delphi拷贝目录(含子目录)的方法
要实现目录级的拷贝,可以利用Windows API函数ShFileOperation( ),其函数声明如下:
WINSHELLAPI int WINAPI SHFileOperation(
LPSHFILEOPSTRUCT lpFileOp
);
实例:
新建一个工程,其程序示例如下:
unit Unit1;
interface
uses
Windows, Messag ......
动态链接库是一个能够被应用程序和其它的DLL调用的过程和函数的集合体,它里面包含的是公共代码或资源。由于DLL代码使用了内存共享技术,在某些地方windows也给了DLL一些更高的权限,因而DLL中可以实现一些一般程序所不能实现的功能,如实现windows的HOOK、ISAPI等。同时,DLL还为不同语言间代码共享提供了一条方便的途径。因而D ......
// 判断是否是数值型 By yangxiao 2007.7.21
function isNumeric(strText: WideString): Boolean;
var
s: string;
i, l, p: Integer;
begin
Result := False;
l := Length(strText);
if l = 0 then Exit;
s := '';
for i:=1 to l do
......
开发步骤:
1、创建ActiveX Library工程。
2、创建COM Object。
3、创建Type Library,并创建相应接口。
4、创建接口对应的函数和实现。
具体如下:
3、创建Type Library,并创建相应接口。
view|type library
找到已经生成的type library,其实和TLB文件是对应的。
我们可以看到上一步生成的对象也含在里面。
我 ......
Delphi中调用Windows自带的图片和传真浏览器查看图片,可以旋转图片也可以调用画图程序编辑图像。自己写不出来好的代码,就用系统自带的好了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,ShellAPI;
type
TForm1 = class(TFo ......