下面源码我不知道是delphi有问题,还是我编得有问题,总是提示memo2没有定义,搞不懂 unit sixUnit1; interface uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinProcs; type ts=array[1..26] of cardinal;
type
TForm1 = class(TForm)
Memo2: TMemo;
Button1: TButton; Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} 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 securityattributes }
nil, { pointer to thread securityattributes }
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);
end;
end;
procedure aqhuf(var aa: ts);
var i,wf:integer;
begin
wf:=winexecAndWait32('huf.exe >c:\temp\arj.txt',SW_SHOW);
Memo2.lines.loadfromfile('c:\temp\arj.txt');
for i:=1 to 26 do
aa[i]:=strtoint('memo2.Lines[i]');
end;
procedure TForm1.Button1Click(Sender: TObject);
var a: array[0..25] of integer;
i:integer;
begin { winexec('huf.exe /c >abc.txt',sw_hide);
memo1.lines.loadfromfile('abc.txt');
}
end; procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end; end.
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, WinProcs; type ts=array[1..26] of cardinal;
type
TForm1 = class(TForm)
Memo2: TMemo;
Button1: TButton; Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.dfm} 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 securityattributes }
nil, { pointer to thread securityattributes }
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);
end;
end;
procedure aqhuf(var aa: ts);
var i,wf:integer;
begin
wf:=winexecAndWait32('huf.exe >c:\temp\arj.txt',SW_SHOW);
Memo2.lines.loadfromfile('c:\temp\arj.txt');
for i:=1 to 26 do
aa[i]:=strtoint('memo2.Lines[i]');
end;
procedure TForm1.Button1Click(Sender: TObject);
var a: array[0..25] of integer;
i:integer;
begin { winexec('huf.exe /c >abc.txt',sw_hide);
memo1.lines.loadfromfile('abc.txt');
}
end; procedure TForm1.Button2Click(Sender: TObject);
begin
application.Terminate;
end; end.
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货