this slowpoke moves

Browse Router in Default Browser

uses ExtCtrls, Registry, ShellApi

//

function GetAppName(Doc: string): string;
var
 FN, DN, RES: array[0..255] of char;
begin
 StrPCopy(FN, DOC);
 DN[0] := #0;
 RES[0] := #0;
 FindExecutable(FN, DN, RES);
 Result := StrPas(RES);
end;

function GetTempFile(const Extension: string): string;
var
 Buffer: array[0..MAX_PATH] of char;
 aFile: string;
begin
 GetTempPath(SizeOf(Buffer) - 1, Buffer);
 GetTempFileName(Buffer, 'TMP', 0, Buffer);
 SetString(aFile, Buffer, StrLen(Buffer));
 Result := ChangeFileExt(aFile, Extension);
end;

function NavigateTo(const aURL: String): Integer;
var
  DefaultBrowser: String;
begin
  DefaultBrowser := Form1.Label1.Caption;
  if (DefaultBrowser <> '') then
    Result := ShellExecute(0, 'open', PChar(DefaultBrowser),
      PChar(aURL), nil, SW_SHOWNORMAL) else
  Result := ShellExecute(0, 'open', PChar(aURL),
      nil, nil, SW_SHOWNORMAL);
end;

procedure TForm1.FormCreate(Sender: TObject);
var
 f: System.Text;
 temp: string;
begin
 // get a unique temporary file name
 temp := GetTempFile('.htm');
 // Create the file
 AssignFile(f, temp);
 rewrite(f);
 closefile(f);
 // Show the path to the browser
 Label1.Caption :=  (GetAppName(temp));
 // Finally delete the temporary file
 Erase(f);
end;
Browse :
procedure TForm1.Button1Click(Sender: TObject);
begin
  NavigateTo('192.168.0.1');
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate