我给你一些代码,是执行外部程序的。各有特点,你可以选择用
另,你想存成什么扩展名,就存成什么扩展名,至于一个文件用什么程序打开
只有存这个文件的人知道(你知道我的意思?)。对于阵列的存取,我没有
研究过,不过可以用笨的方法,一行一列存取。如果数据多,试用循环吧。
1/执行一程序并等待其结束.
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 security
attributes }
nil, { pointer to thread security
attributes }
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;
2、执行外部程序另一法.
uses ShellAPI; // 提供 ShellExecute 函数在
demos/doc/filmanex目录下,
有一FMXUtils中提供各种文件操作增强函数,
其中Function ExecuteFile(filename,params,WDir,SW_SHOW)
可运行外部程序。
3、执行外部程序.
procedure TForm1.Button1Click(Sender: TObject);
var
sCommandLine: string;
bCreateProcess: boolean;
lpStartupInfo: TStartupInfo;
lpProcessInformation: TProcessInformation;
begin
sCommandLine := 'D:/TEMP/TEST.EXE';
// 填入 StartupInfo
FillChar(lpStartupInfo, Sizeof(TStartupInfo), #0);
lpStartupInfo.cb := Sizeof(TStartupInfo);
lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
lpStartupInfo.wShowWindow := SW_NORMAL;
bCreateProcess := CreateProcess(nil, PChar(sCommandLine),
nil, nil, True, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS,
nil, nil, lpStartupInfo, lpProcessInformation);
end;