第1个问题: CVI链接ADOæ•°æ®åº“问题. 已解决~~ä¸é”™~~~ä¸è¿‡è¿˜æ˜¯åœ¨æ“作记录和å—段时比delphi麻烦很多~~~
//建立数æ®åº“è”接,并获得è”接å¥æŸ„ // hdbc = DBConnect ("Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=D:\LabWindows\14\user.mdb;"); // hdbc = DBConnect ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\LabWindows\14\user.mdb;Persist Security Info=False"); hdbc = DBConnect ("Provider=MSDASQL.1;Persist Security Info=False;Data Source=client"); // hdbc = DBConnect ("DSN=client"); DisplayPanel (panelHandle); RunUserInterface (); DiscardPanel (panelHandle); //当退出应用程åºæ—¶ï¼Œå…³é—æ•°æ®åº“连接 DBDisconnect (hdbc);
第2个问题: CVI调用控制å°ç¨‹åºå¹¶å–其结果问题 如CreateProcess(). 在delphié‡Œæ˜¯è¿™æ ·çš„: function TForm1.WinExecAndWait32(FileName: string; Visibility: Integer; var ShowString: string): Cardinal; var sa: TSecurityAttributes; hReadPipe, hWritePipe: THandle; ret: BOOL; // strBuff: array[0..255] of Char; strBuff: array[0..4095] of Char; lngBytesread: DWORD; WorkDir: String; StartupInfo: TStartupInfo; ProcessInfo: TProcessInformation; begin FillChar(sa, Sizeof(sa), #0); sa.nLength := Sizeof(sa); sa.bInheritHandle := True; sa.lpSecurityDescriptor := nil; CreatePipe(hReadPipe, hWritePipe, @sa, 0);
WorkDir := ExtractFileDir(Application.ExeName); FillChar(StartupInfo, Sizeof(StartupInfo), #0); StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES; StartupInfo.wShowWindow := Visibility;
StartupInfo.hStdOutput := hWritePipe; StartupInfo.hStdError := hWritePipe;
if not CreateProcess( nil, PChar(FileName), { pointer to command line string } @sa, { pointer to process security attributes } @sa, { pointer to thread security attributes } True, { handle inheritance flag } // CREATE_NEW_CONSOLE or { creation flags } NORMAL_PRIORITY_CLASS, nil, { pointer to new environment block } PChar(WorkDir), { pointer to current directory name, PChar} StartupInfo, { pointer to STARTUPINFO } ProcessInfo) { pointer to PROCESS_INF } then begin Result := INFINITE {-1}; end else begin ret := CloseHandle(hWritePipe); ShowString := '; while ret do begin FillChar(strBuff, Sizeof(strBuff), #0); ret := ReadFile(hReadPipe, strBuff, 256, lngBytesread, nil); ShowString := ShowString + strBuff; end;
Application.ProcessMessages; WaitforSingleObject(ProcessInfo.hProcess, INFINITE);// GetExitCodeProcess(ProcessInfo.hProcess, Result); CloseHandle(ProcessInfo.hProcess); { to prevent memory leaks } CloseHandle(ProcessInfo.hThread); CloseHandle(hReadPipe); end; end;
if WinExecAndWait32(str, ShowModeSele, buff) = 0 then Memo1.Lines.Add(buff);
è¿™æ ·å³å¯æ”¶åˆ°è¿›ç¨‹FileName(EXE文件)在DOSç•Œé¢çš„显示结果.
下图就是Keil应用CreateProcess()回显的æˆåŠŸä¾‹å,我用以上程åºä¹Ÿè°ƒé€šäº†. æ°´æ½é‡Œåº”该有帖图.
先在æ¤æ„Ÿè°¢äº†~~~ |