如何让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;
 
相关文档:
技术交流,DH讲解. 最近和肥鸟交流了下关于字符串方面的知识,而这篇文章是很久以前写的,现在发出来吧. 我们写两段代码来对比下:
第一个用Copy函数:
procedure TForm1.Button1Click(Sender: TObject);
var
a,c:Cardinal;
n:Integer;
D:Double;
i:Integer;
b:string;
begin
c:=0; ......
在Delphi里实现MD5加密其实很容易!方法如下:
在Uses单元中引用 IdHashMessageDigest,IdGlobal, IdHash 单元,再写如下代码
即可以达到MD5的实现。
示例代码
procedure
TForm
1.Button1Click(Sender: TObject);
var
MyMD5: TIdHashMessageDigest5;
Digest: T4x4LongWordRecord;
begin
MyMD5 := T ......
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm2 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
......
类的事件
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TMyEvent = procedure of object; //不带参数的过程
TMyEventExt = procedure(AName: string) of object; //带参数的过程
TForm1 = class(TForm)
......
在设计数据库应用程序的时候,经常需要将一些信息从程序中独立出来,以保证程序的可移植性。其中最重要的信息就是数据库的连接参数。
在Delphi中,获得正确的数据库连接参数的方法十分简单,你只需要建立一个数据模块,在其中添加一个ADO Connection,双击之,然后在弹出的窗口中选“Use Connection String”,单 ......