Changeset 141 for trunk/Packages
- Timestamp:
- Dec 10, 2016, 4:21:11 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/UCommon.pas
r3 r141 6 6 7 7 uses 8 {$IFDEF Windows}Windows,{$ENDIF} 8 {$ifdef Windows}Windows,{$endif} 9 {$ifdef Linux}baseunix,{$endif} 9 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, 10 11 FileUtil; //, ShFolder, ShellAPI; … … 65 66 procedure FreeThenNil(var Obj); 66 67 function RemoveQuotes(Text: string): string; 68 function ComputerName: string; 69 function OccurenceOfChar(What: Char; Where: string): Integer; 70 function GetDirCount(Dir: string): Integer; 71 function MergeArray(A, B: array of string): TArrayOfString; 67 72 68 73 … … 287 292 L: LongWord; 288 293 begin 289 290 294 L := MAX_USERNAME_LENGTH + 2; 291 295 SetLength(Result, L); … … 302 306 end; 303 307 end; 304 308 {$endif} 309 310 function ComputerName: string; 311 {$ifdef mswindows} 312 const 313 INFO_BUFFER_SIZE = 32767; 314 var 315 Buffer : array[0..INFO_BUFFER_SIZE] of WideChar; 316 Ret : DWORD; 317 begin 318 Ret := INFO_BUFFER_SIZE; 319 If (GetComputerNameW(@Buffer[0],Ret)) then begin 320 Result := UTF8Encode(WideString(Buffer)); 321 end 322 else begin 323 Result := 'ERROR_NO_COMPUTERNAME_RETURNED'; 324 end; 325 end; 326 {$endif} 327 {$ifdef unix} 328 var 329 Name: UtsName; 330 begin 331 fpuname(Name); 332 Result := Name.Nodename; 333 end; 334 {$endif} 335 336 {$ifdef windows} 305 337 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 306 338 const … … 417 449 418 450 procedure OpenWebPage(URL: string); 419 var420 Process: TProcess;421 Browser, Params: string;422 451 begin 423 452 OpenURL(URL); 424 {try425 Process := TProcess.Create(nil);426 Browser := '';427 //FindDefaultBrowser(Browser, Params);428 //Process.Executable := Browser;429 //Process.Parameters.Add(Format(Params, [ApplicationInfo.HomePage]);430 Process.CommandLine := 'cmd.exe /c start ' + URL;431 Process.Options := [poNoConsole];432 Process.Execute;433 finally434 Process.Free;435 end;}436 453 end; 437 454 … … 448 465 end; 449 466 467 function OccurenceOfChar(What: Char; Where: string): Integer; 468 var 469 I: Integer; 470 begin 471 Result := 0; 472 for I := 1 to Length(Where) do 473 if Where[I] = What then Inc(Result); 474 end; 475 476 function GetDirCount(Dir: string): Integer; 477 begin 478 Result := OccurenceOfChar(DirectorySeparator, Dir); 479 if Copy(Dir, Length(Dir), 1) = DirectorySeparator then 480 Dec(Result); 481 end; 482 483 function MergeArray(A, B: array of string): TArrayOfString; 484 var 485 I: Integer; 486 begin 487 SetLength(Result, Length(A) + Length(B)); 488 for I := 0 to Length(A) - 1 do 489 Result[I] := A[I]; 490 for I := 0 to Length(B) - 1 do 491 Result[Length(A) + I] := B[I]; 492 end; 493 494 450 495 451 496 initialization
Note:
See TracChangeset
for help on using the changeset viewer.