For many reasons you may need the installed BDE (Borland Database Engine) version. One of them (the main one probably) is that BDE versions are not always compatible with each other. Therefore you may want to use different code/components at runtime.
Use the code below to determine what version of BDE is installed on the system. The first snippet does not use the registry while the second one does.
1. Without quering the Windows system registry:
var
BDEVersion: SYSVersion;
...
DbiGetSysVersion(BDEVersion);
// BDEVersion.iVersion - BDE version
...
2. With the use of the Windows system registry:
uses
BDE, Registry, Windows;
...
function GetBDEVersion: string;
var
hDll: hWnd;
pFunc: Pointer;
sIdAPI: string;
SysVer: SYSVersion;
SysVerProc: TSYSVerProc;
begin
Result := '';
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
if OpenKey('CLSID{FB99D710-18B9-11D0-A4CF-00A024C91936}InProcServer32',
False) then begin
sIdAPI := ReadString('');
CloseKey;
end;
finally
Free;
end;
hDll := LoadLibrary(PChar(idapi));
if hDll <> 0 then
try
pFunc := GetProcAddress(hDll, 'DbiGetSysVersion');
if pFunc <> nil then begin
SysVerProc := pFunc;
SysVerProc(SysVer);
Result := IntToStr(SysVer.iVersion);
Insert('.', Result, 2);
end;
finally
FreeLibrary(hDll);
end;
end;
Categories: Databases Tags: bde, borland, borland database engine, code, database, Delphi, engine, faq, free, get, retrieve, source code, tip, trick, version
Accessing Internet Explorer favorites is not hard since they are nothing more than files and folders. All you have to basically do is find the IE Favorites folder, then read it’s structure and file list. Once this is done you will need to read the URL that’s in each of the files. Sounds easy? You can always use the code below… ;->
function GetIEFavorites(const Path: string): TStrings;
var
Buffer: array[0..2047] of Char;
iFound: Integer;
Dir, FileName, Path: string;
SearchRec: TSearchRec;
Links: TStrings;
begin
Links := TStringList.Create;
// Get all file names in the favourites path
Path := FavPath + '*.url';
Dir := ExtractFilepath(Path);
iFound := FindFirst(Path, faAnyFile, searchrec);
while iFound = 0 do begin
// Get now URLs from files
Setstring(FileName, Buffer, GetPrivateProfilestring('InternetShortcut',
PChar('URL'), nil, Buffer, SizeOf(Buffer), PChar(Dir + SearchRec.Name)));
Links.Add(FileName);
iFound := FindNext(SearchRec);
end;
// Find subfolders
iFound := FindFirst(Dir + '*.*', faAnyFile, searchrec);
while iFound = 0 do begin
if ((SearchRec.Attr and faDirectory) > 0) and (SearchRec.Name[1] <> '.') then
Links.Addstrings(GetIEFavorites(dir + '' + SearchRec.Name));
iFound := FindNext(searchrec);
end;
FindClose(SearchRec);
Result := Links;
end;
...
procedure FreePidl(pIDL: PItemIDList);
var
Allocator: IMalloc;
begin
if Succeeded(SHGetMalloc(Allocator)) then begin
Allocator.Free(pIDL);
{$ifdef VER100}
Allocator.Release;
{$endif}
end;
end;
...
var
FavPath: array[0..MAX_PATH] of Char;
pIDL : PItemIDList;
begin
if Succeeded(ShGetSpecialFolderLocation(Handle, CSIDL_FAVORITES, pIDL)) then begin
if ShGetPathfromIDList(pIDL, FavPath) then
ListBox1.Items := GetIEFavourites(StrPas(FavPath));
// We are responsible for freeing the PItemIDList pointer with the
// Shell's IMalloc interface
FreePIDL(pIDL);
end;
end;
Categories: Internet / LAN Tags: accessing internet, bookmarks, borland, code, Delphi, download, explorer, favorites, favorites folder, filename path, folder, freeware, get, getprivateprofilestring, how to, ie, internet, internet explorer, internet explorer favorites, open source, path string, retrieve, source, tip, trick