- Timestamp:
- Feb 15, 2022, 10:14:04 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/UCommon.pas
r556 r557 13 13 type 14 14 TArrayOfByte = array of Byte; 15 TArrayOfString = array of string;16 15 TExceptionEvent = procedure(Sender: TObject; E: Exception) of object; 17 16 … … 51 50 function ComputerName: string; 52 51 procedure DeleteFiles(APath, AFileSpec: string); 52 function Explode(Separator: Char; Data: string): TStringArray; 53 53 procedure ExecuteProgram(Executable: string; Parameters: array of string); 54 54 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog); … … 65 65 function LoadFileToStr(const FileName: TFileName): AnsiString; 66 66 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 67 function MergeArray(A, B: array of string): T ArrayOfString;67 function MergeArray(A, B: array of string): TStringArray; 68 68 function OccurenceOfChar(What: Char; Where: string): Integer; 69 69 procedure OpenWebPage(URL: string); … … 291 291 end; 292 292 293 function Explode(Separator: char; Data: string): TArrayOfString; 294 begin 295 Result := nil; 296 SetLength(Result, 0); 297 while Pos(Separator, Data) > 0 do begin 293 function Explode(Separator: Char; Data: string): TStringArray; 294 var 295 Index: Integer; 296 begin 297 Result := Default(TStringArray); 298 repeat 299 Index := Pos(Separator, Data); 300 if Index > 0 then begin 301 SetLength(Result, Length(Result) + 1); 302 Result[High(Result)] := Copy(Data, 1, Index - 1); 303 Delete(Data, 1, Index); 304 end else Break; 305 until False; 306 if Data <> '' then begin 298 307 SetLength(Result, Length(Result) + 1); 299 Result[High(Result)] := Copy(Data, 1, Pos(Separator, Data) - 1); 300 Delete(Data, 1, Pos(Separator, Data)); 301 end; 302 SetLength(Result, Length(Result) + 1); 303 Result[High(Result)] := Data; 304 end; 305 306 {$IFDEF Windows} 308 Result[High(Result)] := Data; 309 end; 310 end; 311 312 {$IFDEF WINDOWS} 307 313 function GetUserName: string; 308 314 const … … 312 318 begin 313 319 L := MAX_USERNAME_LENGTH + 2; 320 Result := Default(string); 314 321 SetLength(Result, L); 315 322 if Windows.GetUserName(PChar(Result), L) and (L > 0) then begin … … 325 332 end; 326 333 end; 327 {$ endif}334 {$ENDIF} 328 335 329 336 function ComputerName: string; 330 {$ ifdef mswindows}337 {$IFDEF WINDOWS} 331 338 const 332 339 INFO_BUFFER_SIZE = 32767; … … 343 350 end; 344 351 end; 345 {$ endif}346 {$ ifdef unix}352 {$ENDIF} 353 {$IFDEF UNIX} 347 354 var 348 355 Name: UtsName; … … 352 359 Result := Name.Nodename; 353 360 end; 354 {$ endif}355 356 {$ ifdef windows}361 {$ENDIF} 362 363 {$IFDEF WINDOWS} 357 364 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 358 365 const … … 432 439 procedure LoadLibraries; 433 440 begin 434 {$IFDEF W indows}441 {$IFDEF WINDOWS} 435 442 DLLHandle1 := LoadLibrary('secur32.dll'); 436 443 if DLLHandle1 <> 0 then … … 443 450 procedure FreeLibraries; 444 451 begin 445 {$IFDEF W indows}452 {$IFDEF WINDOWS} 446 453 if DLLHandle1 <> 0 then FreeLibrary(DLLHandle1); 447 454 {$ENDIF} … … 509 516 end; 510 517 511 function MergeArray(A, B: array of string): T ArrayOfString;512 var 513 I: Integer; 514 begin 515 Result := Default(T ArrayOfString);518 function MergeArray(A, B: array of string): TStringArray; 519 var 520 I: Integer; 521 begin 522 Result := Default(TStringArray); 516 523 SetLength(Result, Length(A) + Length(B)); 517 524 for I := 0 to Length(A) - 1 do
Note:
See TracChangeset
for help on using the changeset viewer.