delphi 外部程序..进度条问题.. ( 积分: 100 )

  • 主题发起人 主题发起人 hcnet
  • 开始时间 开始时间
H

hcnet

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Gauges, ComCtrls;
type
TForm1 = class(TForm)
Gauge1: TGauge;
Timer1: TTimer;
StatusBar1: TStatusBar;
procedure Timer1Timer(Sender: TObject);
procedure StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel;
const Rect: TRect);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure WinExecAndWait(CommandLine:String);
var ComLineBuffer: array[0..512] of char;
StartupInfo: TStartupInfo;
ProcessInfo: TProcessInformation;
Re:Cardinal;
begin
StrPCopy(ComLineBuffer,CommandLine);
FillChar(StartupInfo, Sizeof(StartupInfo), #0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow := SW_HIDE;
if CreateProcess(nil,
ComLineBuffer, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
True, { handle inheritance flag }
CREATE_NEW_CONSOLE or { creation flags }
NORMAL_PRIORITY_CLASS,
nil, { pointer to new environment block }
nil, { pointer to current directory name, PChar}
StartupInfo, { pointer to STARTUPINFO }
ProcessInfo) { pointer to PROCESS_INF }
then
begin
WaitforSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, Re);
CloseHandle(ProcessInfo.hProcess);
{ to prevent memory leaks }
CloseHandle(ProcessInfo.hThread);
end;
end;
// 等待EXE 执行完毕 函数....
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel;
const Rect: TRect);
begin
gauge1.BoundsRect := Rect ;
//进度条..坐标范围...
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if gauge1.Progress = 100 then
begin
gauge1.Progress := 0;
end
else
gauge1.Progress :=gauge1.Progress +1 ;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
gauge1.Parent:=StatusBar1 ;
WinExecAndWait('cmd /c move d:/bak/*.* e:/bak/');
//这个只是打个比方.调用的员外部程序
end;
end.

不知有哪兄弟..有做过此类的,例子......................调用外部程序运行...进度条....跟随程序同步.........
现在目前 进度条 在程序开始运行的时候..无法进行同步....可有函数
可以做到吗.??

看来这个例子..没有朋友会的了.........
 
用回调函数!
 
兄弟..能具体一些吗....能举个例子吗.
两天了就兄弟您.回了一贴..给你加分...发现现在这个论坛好像..讨论.好像不如以前了..
 
兄弟..做例子吧........这个问题.好几天..兄弟我太急了..一直在网上没找到相关的资料..................回调函数看过了.好像..无法实现哦.
 

Similar threads

I
回复
0
查看
622
import
I
S
回复
0
查看
763
SUNSTONE的Delphi笔记
S
I
回复
0
查看
554
import
I
后退
顶部