程序博客网 > excel筛选不重复数据
来源:互联网 发布:excel筛选不重复数据 编辑:程序博客网 时间:2024/05/28 09:31
function RunDos(const CommandLine: String): String;var sa:TSecurityAttributes; sd: SECURITY_DESCRIPTOR; lpsa: PSecurityAttributes; hReadPipe,hWritePipe :THandle; si: TStartupInfo; pi: TProcessInformation ; dest: array [0..4095] of char; BytesRead: Dword; function IsWindowsNT: Boolean; var osv: OSVERSIONINFO ; begin; osv.dwOSVersionInfoSize := sizeof(osv); GetVersionEx(osv); if (osv.dwPlatformId = VER_PLATFORM_WIN32_NT) then Result :=TRUE ELSE rESULT:=False; end;begin Result:='调用失败'; lpsa := nil; if (IsWindowsNT) then begin InitializeSecurityDescriptor(@sd, SECURITY_DESCRIPTOR_REVISION); SetSecurityDescriptorDacl(@sd, true, nil, false); sa.nLength := sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle := true; sa.lpSecurityDescriptor := @sd; lpsa := @sa; end; assert(CreatePipe(hReadPipe,hWritePipe,lpsa,2500000)); GetStartupInfo(si); si.cb := sizeof(TStartupInfo); si.dwFlags := STARTF_USESHOWWINDOW + STARTF_USESTDHANDLES; si.wShowWindow := SW_HIDE; si.hStdOutput := hWritePipe; si.hStdError := hWritePipe; CreateProcess(nil,PChar(CommandLine),nil,nil,TRUE,0,nil,nil,si,pi); CloseHandle(pi.hThread); WaitForSingleObject(pi.hProcess, INFINITE); if ReadFile(hReadPipe,dest,sizeof(dest),BytesRead,nil) then Result:=Copy(String(dest),1,BytesRead); CloseHandle(hReadPipe); CloseHandle(hWritePipe); CloseHandle(pi.hProcess);end;