由于好久没用delphi 一切都很陌生
问题 第一步 调用数据库bcp.exe 导出
第2步 调用C:\AA.EXE
第3步 调用数据库bcp.exe导入
要求 确保每一步 执行完之后 再执行下一步
也就是创建进程来确保要求要完整代码 因为好久没用了
顶的 灌水的 简单2据的一律没分
问题 第一步 调用数据库bcp.exe 导出
第2步 调用C:\AA.EXE
第3步 调用数据库bcp.exe导入
要求 确保每一步 执行完之后 再执行下一步
也就是创建进程来确保要求要完整代码 因为好久没用了
顶的 灌水的 简单2据的一律没分
用WaitForSingleObject等
begin
winexec('c:\发帖.exe',sw_show);
end;
1.
uses ShellAPI;
ShellExecute
2.winexec
WaitForSingleObject等待所调用的程序结束
procedure TForm1.Button1Click(Sender: TObject);
var
pw: string;
sInfo: TStartupInfo; {进程启动信息}
pInfo: TProcessInformation; {进程信息}
cmdLine: string;
exitCode: Cardinal;
SysDirectry: string;
ServerName: string;
DBName: string;
begin
ServerName := '.';
DBName := 'water';
pw := '';
SysDirectry := ExtractFilePath(Application.ExeName) + '..\BaseData';
try
cmdLine := Format('"%sbcp.exe" %s.dbo.%s in "%s\%s.dat" -c -q -t **\t** -r \n -S %s -U sa -P %s',
[ExtractFilePath(Application.ExeName), DBName, 'dian_tab', SysDirectry, 'dian_tab', ServerName, pw]);
FillChar(sInfo, sizeof(sInfo), #0);
sInfo.cb := SizeOf(sInfo);
sInfo.dwFlags := STARTF_USESHOWWINDOW;
sInfo.wShowWindow := SW_HIDE;
if not CreateProcess(nil, pchar(cmdLine), nil, nil, false, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, sInfo, pInfo) then
begin
MessageBox(Application.handle, '指定程序启动失败!', '错误', MB_OK or MB_ICONSTOP);
Abort;
end
else
begin
WaitForSingleObject(pInfo.hProcess, INFINITE);
GetExitCodeProcess(pInfo.hProcess, exitCode);
end;
finally
end;
end;
// 打开目录
ShellExecute(NULL, "open", "c:nwindows", NULL, NULL, 0);
// 运行外部程序
ShellExecute(NULL, "open", "c:nwindowsnnotepad.exe", "c:xxx.txt", NULL, SW_SHOWNORMAL);
// 打印文件
ShellExecute(NULL, "print", "c:nxxx.doc", NULL, NULL, 0);
// 打开网页
ShellExecute(NULL, "open", "https://www.baidu.com/", NULL, NULL, 0);