Changeset 282


Ignore:
Timestamp:
Oct 10, 2011, 1:34:02 PM (13 years ago)
Author:
george
Message:
  • Addded: Function for open web page.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r260 r282  
    77uses
    88  {$IFDEF Windows}Windows,{$ENDIF}
    9   Classes, SysUtils, SpecializedList, StrUtils, Dialogs,
     9  Classes, SysUtils, SpecializedList, StrUtils, Dialogs, Process,
    1010  FileUtil; //, ShFolder, ShellAPI;
    1111
     
    3636{$ENDIF}
    3737
    38 function IntToBin(Data: Cardinal; Count: Byte): string;
     38function IntToBin(Data: Int64; Count: Byte): string;
     39function BinToInt(BinStr: string): Int64;
    3940function TryHexToInt(Data: string; var Value: Integer): Boolean;
    4041function TryBinToInt(Data: string; var Value: Integer): Boolean;
     
    5960procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog);
    6061procedure DeleteFiles(APath, AFileSpec: string);
     62procedure OpenWebPage(URL: string);
    6163
    6264
    6365implementation
     66
     67function BinToInt(BinStr : string) : Int64;
     68var
     69  i : byte;
     70  RetVar : Int64;
     71begin
     72  BinStr := UpperCase(BinStr);
     73  if BinStr[length(BinStr)] = 'B' then Delete(BinStr,length(BinStr),1);
     74  RetVar := 0;
     75  for i := 1 to length(BinStr) do begin
     76    if not (BinStr[i] in ['0','1']) then begin
     77      RetVar := 0;
     78      Break;
     79    end;
     80    RetVar := (RetVar shl 1) + (byte(BinStr[i]) and 1) ;
     81  end;
     82
     83  Result := RetVar;
     84end;
    6485
    6586function BinToHexString(Source: AnsiString): string;
     
    179200end;*)
    180201
    181 function IntToBin(Data: Cardinal; Count: Byte): string;
     202function IntToBin(Data: Int64; Count: Byte): string;
    182203var
    183204  I: Integer;
     
    344365end;
    345366
     367procedure OpenWebPage(URL: string);
     368var
     369  Process: TProcess;
     370  Browser, Params: string;
     371begin
     372  try
     373    Process := TProcess.Create(nil);
     374    Browser := '';
     375    //FindDefaultBrowser(Browser, Params);
     376    //Process.Executable := Browser;
     377    //Process.Parameters.Add(Format(Params, [ApplicationInfo.HomePage]);
     378    Process.Executable := 'cmd.exe';
     379    Process.Parameters.Add('/c');
     380    Process.Parameters.Add('start');
     381    Process.Parameters.Add(URL);
     382    Process.Options := [poNoConsole];
     383    Process.Execute;
     384  finally
     385    Process.Free;
     386  end;
     387end;
     388
    346389
    347390initialization
Note: See TracChangeset for help on using the changeset viewer.