How to Start Microsoft Internet Explorer

Posted on December 15th, 1999 in General, Internet / LAN | 1 Comment »

Since Internet Explorer is a part of Microsoft Windows 95 (OSR 2 and OSR 2.1), 98, ME, NT, 2000, XP or Windows Vista you may want to add a link to your home page that will start Microsoft Internet Explorer (MSIE). Here’s the code to do so:

uses
  Windows, {$ifdef ver90} OLEAuto {$else} ComObj {$endif};
...
procedure StartIE(sURL: string);
var
  hwndHandle: HWnd;
  vIE: Variant;
begin
  if VarIsEmpty(vIE) then begin
    vIE := CreateOleObject('InternetExplorer.Application');
    vIE.Visible := True;
    vIE.Navigate(sUrl);
  end else begin
    hwndHandle := FindWindow('IEFrame', nil);
    if hwndHandle <> 0 then begin
      vIE.Navigate(sURL);
      SetForegroundWindow(hwndHandle);
    end else
      ShowMessage('Can''t open Microsoft Internet Explorer!');
  end;
end;

Example:

StartIE('http://www.delphifaq.net/');

How to Create Multiple Directories

Posted on December 15th, 1999 in General | 1 Comment »

The standard MkDir() function can create only one directory, it can not create subdirectories at one time. This function allows you to create multiple directories (directories inside directories). Delphi 4+ has the ForceDirectories() routine which does the same thing. It is declared in the FileCtrl unit.

uses
  SysUtils, FileCtrl;
...
procedure MkDirMulti(sPath: string);
begin
  if sPath[Length(sPath)] = '' then
    sPath := Copy(sPath, 1, Length(sPath - 1));
  if (Length(sPath) < 3) or DirectoryExists(sPath) then
    Exit;
  MkDirMulti(SysUtils.ExtractFilePath(sPath));

  try
    MkDir(sPath);
  except
    { Handle errors }
  end;
end;

Example:

MkDirMulti('C:\\Program Files\\My Game\\Audio\\Speech');