Category Archives: Delphi

Delphi rs232 ComPort Libraries

  These components have demo applications which act as terminals with full duplex capability. See: http://www.torry.net/authorsmore.php?id670 http://www.torry.net/pages.php?id8 http://sourceforge.net/projects/tpapro/ http://sourceforge.net/projects/comport/ Have a look at the source code and try the demos on your hardware to see what works best for you.    

Get Bluetooth com in delphi

function GetBlutoothComPort: String; var S, S1: String; Item: Integer; Reg: TRegistry; KeyList1, KeyList2: TStringList; begin Reg := TRegistry.Create; if Reg = nil then begin fmDebug.AddDebugItem( ‘Error creating Reg ‘ ); exit; end; KeyList1 := TStringList.Create; if KeyList1 = nil then begin fmDebug.AddDebugItem( ‘Error creating KeyList1 ‘ ); exit; end; KeyList2

Borlad database engine errors

BDE Error list: $0000 (0) = Successful completion. $0021 (33) = System Error $0022 (34) = Object of Interest Not Found $0023 (35) = Physical Data Corruption $0024 (36) = I/O Related Error $0025 (37) = Resource or Limit Error $0026 (38) = Data Integrity Violation $0027 (39) = Invalid

Download a file from Internet

{1.} uses URLMon, ShellApi; function DownloadFile(SourceFile, DestFile: string): Boolean; begin try Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0; except Result := False; end; end; procedure TForm1.Button1Click(Sender: TObject); const // URL Location SourceFile = ‘http://www.google.com/intl/de/images/home_title.gif’; // Where to save the file DestFile = ‘c:tempgoogle-image.gif’; begin if DownloadFile(SourceFile, DestFile) then begin ShowMessage(‘Download succesful!’); // Show downloaded image in your browser ShellExecute(Application.Handle, PChar(‘open’), PChar(DestFile), PChar(”), nil, SW_NORMAL) end else ShowMessage(‘Error while downloading ‘ + SourceFile) end; // Minimum availability: Internet Explorer 3.0 // Minimum operating systems Windows NT 4.0, Windows 95 {********************************************************} {2.} uses Wininet; function DownloadURL(const aUrl: string): Boolean; var hSession: HINTERNET; hService: HINTERNET; lpBuffer: array[0..1024 + 1] of Char; dwBytesRead: DWORD; begin Result := False; // hSession := InternetOpen( ‘MyApp’, INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0); hSession := InternetOpen(‘MyApp’, INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); try if Assigned(hSession) then begin hService := InternetOpenUrl(hSession, PChar(aUrl), nil, 0, 0, 0); if Assigned(hService) then try

Copy a file

{ The CopyFile function copies an existing file to a new file. CopyFile( lpExistingFileName : PChar, // name of an existing file lpNewFileName : PChar,      // name of new file bFailIfExists : Boolean);   // operation if file exists bFailIfExists: Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. } var fileSource, fileDest: string; begin fileSource := ‘C:SourceFile.txt’; fileDest := ‘G:DestFile.txt’; CopyFile(PChar(fileSource), PChar(fileDest), False); end;