Changeset 34 for trunk/Components/Common
- Timestamp:
- Nov 25, 2017, 12:27:33 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 3 3 backup 4 4 tunneler.exe 5 tunneler.dbg 6 tunneler.lps 5 7 heaptrclog.trc 6 tunneler.lps 8 Components/Common/Languages/*.mo 9 Components/CoolTranslator/Demo/lib
-
- Property svn:ignore
-
trunk/Components/Common/Common.lpk
r31 r34 1 <?xml version="1.0" ?>1 <?xml version="1.0" encoding="UTF-8"?> 2 2 <CONFIG> 3 3 <Package Version="4"> 4 4 <PathDelim Value="\"/> 5 5 <Name Value="Common"/> 6 <Type Value="RunAndDesignTime"/> 6 7 <AddToProjectUsesSection Value="True"/> 7 8 <Author Value="Chronos (robie@centrum.cz)"/> … … 12 13 <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> 13 14 </SearchPaths> 14 <Other>15 <CompilerMessages>16 <UseMsgFile Value="True"/>17 </CompilerMessages>18 <CompilerPath Value="$(CompPath)"/>19 </Other>20 15 </CompilerOptions> 21 16 <Description Value="Various libraries"/> 22 17 <License Value="GNU/GPL"/> 23 18 <Version Minor="7"/> 24 <Files Count=" 15">19 <Files Count="20"> 25 20 <Item1> 26 21 <Filename Value="StopWatch.pas"/> … … 87 82 <UnitName Value="UApplicationInfo"/> 88 83 </Item15> 84 <Item16> 85 <Filename Value="USyncCounter.pas"/> 86 <UnitName Value="USyncCounter"/> 87 </Item16> 88 <Item17> 89 <Filename Value="UListViewSort.pas"/> 90 <HasRegisterProc Value="True"/> 91 <UnitName Value="UListViewSort"/> 92 </Item17> 93 <Item18> 94 <Filename Value="UPersistentForm.pas"/> 95 <HasRegisterProc Value="True"/> 96 <UnitName Value="UPersistentForm"/> 97 </Item18> 98 <Item19> 99 <Filename Value="UFindFile.pas"/> 100 <HasRegisterProc Value="True"/> 101 <UnitName Value="UFindFile"/> 102 </Item19> 103 <Item20> 104 <Filename Value="UScaleDPI.pas"/> 105 <HasRegisterProc Value="True"/> 106 <UnitName Value="UScaleDPI"/> 107 </Item20> 89 108 </Files> 90 109 <i18n> 91 110 <EnableI18N Value="True"/> 92 111 <OutDir Value="Languages"/> 112 <EnableI18NForLFM Value="True"/> 93 113 </i18n> 94 <Type Value="RunAndDesignTime"/> 95 <RequiredPkgs Count="2"> 114 <RequiredPkgs Count="3"> 96 115 <Item1> 97 <PackageName Value=" TemplateGenerics"/>116 <PackageName Value="LCL"/> 98 117 </Item1> 99 118 <Item2> 119 <PackageName Value="TemplateGenerics"/> 120 </Item2> 121 <Item3> 100 122 <PackageName Value="FCL"/> 101 123 <MinVersion Major="1" Valid="True"/> 102 </Item 2>124 </Item3> 103 125 </RequiredPkgs> 104 126 <UsageOptions> -
trunk/Components/Common/Common.pas
r31 r34 10 10 StopWatch, UCommon, UDebugLog, UDelay, UPrefixMultiplier, UURI, UThreading, 11 11 UMemory, UResetableThread, UPool, ULastOpenedList, URegistry, 12 UJobProgressView, UXMLUtils, UApplicationInfo, LazarusPackageIntf; 12 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 13 UPersistentForm, UFindFile, UScaleDPI, LazarusPackageIntf; 13 14 14 15 implementation … … 20 21 RegisterUnit('UJobProgressView', @UJobProgressView.Register); 21 22 RegisterUnit('UApplicationInfo', @UApplicationInfo.Register); 23 RegisterUnit('UListViewSort', @UListViewSort.Register); 24 RegisterUnit('UPersistentForm', @UPersistentForm.Register); 25 RegisterUnit('UFindFile', @UFindFile.Register); 26 RegisterUnit('UScaleDPI', @UScaleDPI.Register); 22 27 end; 23 28 -
trunk/Components/Common/Languages/UJobProgressView.po
r31 r34 14 14 msgstr "" 15 15 16 #: ujobprogressview.soperations 17 msgid "Operations" 18 msgstr "" 19 16 20 #: ujobprogressview.spleasewait 17 21 msgid "Please wait..." -
trunk/Components/Common/UApplicationInfo.pas
r31 r34 15 15 private 16 16 FIdentification: Byte; 17 FLicense: string; 17 18 FVersionMajor: Byte; 18 19 FVersionMinor: Byte; … … 47 48 property RegistryKey: string read FRegistryKey write FRegistryKey; 48 49 property RegistryRoot: TRegistryRoot read FRegistryRoot write FRegistryRoot; 50 property License: string read FLicense write FLicense; 49 51 end; 50 52 … … 55 57 procedure Register; 56 58 begin 57 RegisterComponents(' Samples', [TApplicationInfo]);59 RegisterComponents('Common', [TApplicationInfo]); 58 60 end; 59 61 -
trunk/Components/Common/UCommon.pas
r31 r34 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; … … 48 49 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 49 50 function SplitString(var Text: string; Count: Word): string; 51 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 50 52 function GetBit(Variable: QWord; Index: Byte): Boolean; 53 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload; 51 54 procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload; 52 55 procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload; … … 62 65 procedure ExecuteProgram(CommandLine: string); 63 66 procedure FreeThenNil(var Obj); 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; 72 function LoadFileToStr(const FileName: TFileName): AnsiString; 64 73 65 74 … … 105 114 Find := FindFirst(UTF8Decode(Path + AFileSpec), faAnyFile xor faDirectory, SearchRec); 106 115 while Find = 0 do begin 107 DeleteFile UTF8(Path + UTF8Encode(SearchRec.Name));116 DeleteFile(Path + UTF8Encode(SearchRec.Name)); 108 117 109 118 Find := SysUtils.FindNext(SearchRec); … … 284 293 L: LongWord; 285 294 begin 286 287 295 L := MAX_USERNAME_LENGTH + 2; 288 296 SetLength(Result, L); … … 299 307 end; 300 308 end; 301 309 {$endif} 310 311 function ComputerName: string; 312 {$ifdef mswindows} 313 const 314 INFO_BUFFER_SIZE = 32767; 315 var 316 Buffer : array[0..INFO_BUFFER_SIZE] of WideChar; 317 Ret : DWORD; 318 begin 319 Ret := INFO_BUFFER_SIZE; 320 If (GetComputerNameW(@Buffer[0],Ret)) then begin 321 Result := UTF8Encode(WideString(Buffer)); 322 end 323 else begin 324 Result := 'ERROR_NO_COMPUTERNAME_RETURNED'; 325 end; 326 end; 327 {$endif} 328 {$ifdef unix} 329 var 330 Name: UtsName; 331 begin 332 fpuname(Name); 333 Result := Name.Nodename; 334 end; 335 {$endif} 336 337 {$ifdef windows} 302 338 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 303 339 const … … 336 372 end; 337 373 374 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 375 var 376 I: Integer; 377 begin 378 Result := 0; 379 for I := 0 to MaxIndex - 1 do 380 if ((Variable shr I) and 1) = 1 then Inc(Result); 381 end; 382 338 383 function GetBit(Variable:QWord;Index:Byte):Boolean; 339 384 begin … … 341 386 end; 342 387 388 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); 389 begin 390 Variable := (Variable and ((1 shl Index) xor High(QWord))) or (Int64(State) shl Index); 391 end; 392 343 393 procedure SetBit(var Variable:QWord;Index:Byte;State:Boolean); overload; 344 394 begin 345 Variable := (Variable and ((1 shl Index) xor QWord($ffffffffffffffff))) or (QWord(State) shl Index);395 Variable := (Variable and ((1 shl Index) xor High(QWord))) or (QWord(State) shl Index); 346 396 end; 347 397 348 398 procedure SetBit(var Variable:Cardinal;Index:Byte;State:Boolean); overload; 349 399 begin 350 Variable := (Variable and ((1 shl Index) xor Cardinal($ffffffff))) or (Cardinal(State) shl Index);400 Variable := (Variable and ((1 shl Index) xor High(Cardinal))) or (Cardinal(State) shl Index); 351 401 end; 352 402 353 403 procedure SetBit(var Variable:Word;Index:Byte;State:Boolean); overload; 354 404 begin 355 Variable := (Variable and ((1 shl Index) xor Word($ffff))) or (Word(State) shl Index);405 Variable := (Variable and ((1 shl Index) xor High(Word))) or (Word(State) shl Index); 356 406 end; 357 407 … … 400 450 401 451 procedure OpenWebPage(URL: string); 402 var403 Process: TProcess;404 Browser, Params: string;405 452 begin 406 453 OpenURL(URL); 407 {try 408 Process := TProcess.Create(nil); 409 Browser := ''; 410 //FindDefaultBrowser(Browser, Params); 411 //Process.Executable := Browser; 412 //Process.Parameters.Add(Format(Params, [ApplicationInfo.HomePage]); 413 Process.CommandLine := 'cmd.exe /c start ' + URL; 414 Process.Options := [poNoConsole]; 415 Process.Execute; 454 end; 455 456 procedure OpenFileInShell(FileName: string); 457 begin 458 ExecuteProgram('cmd.exe /c start "' + FileName + '"'); 459 end; 460 461 function RemoveQuotes(Text: string): string; 462 begin 463 Result := Text; 464 if (Pos('"', Text) = 1) and (Text[Length(Text)] = '"') then 465 Result := Copy(Text, 2, Length(Text) - 2); 466 end; 467 468 function OccurenceOfChar(What: Char; Where: string): Integer; 469 var 470 I: Integer; 471 begin 472 Result := 0; 473 for I := 1 to Length(Where) do 474 if Where[I] = What then Inc(Result); 475 end; 476 477 function GetDirCount(Dir: string): Integer; 478 begin 479 Result := OccurenceOfChar(DirectorySeparator, Dir); 480 if Copy(Dir, Length(Dir), 1) = DirectorySeparator then 481 Dec(Result); 482 end; 483 484 function MergeArray(A, B: array of string): TArrayOfString; 485 var 486 I: Integer; 487 begin 488 SetLength(Result, Length(A) + Length(B)); 489 for I := 0 to Length(A) - 1 do 490 Result[I] := A[I]; 491 for I := 0 to Length(B) - 1 do 492 Result[Length(A) + I] := B[I]; 493 end; 494 495 function LoadFileToStr(const FileName: TFileName): AnsiString; 496 var 497 FileStream: TFileStream; 498 Read: Integer; 499 begin 500 Result := ''; 501 FileStream := TFileStream.Create(FileName, fmOpenRead); 502 try 503 if FileStream.Size > 0 then begin 504 SetLength(Result, FileStream.Size); 505 Read := FileStream.Read(Pointer(Result)^, FileStream.Size); 506 SetLength(Result, Read); 507 end; 416 508 finally 417 Process.Free; 418 end;} 419 end; 420 421 procedure OpenFileInShell(FileName: string); 422 begin 423 ExecuteProgram('cmd.exe /c start "' + FileName + '"'); 424 end; 509 FileStream.Free; 510 end; 511 end; 512 513 425 514 426 515 initialization -
trunk/Components/Common/UDebugLog.pas
r31 r34 31 31 Items: TListObject; 32 32 Lock: TCriticalSection; 33 procedure Add( Group: string; Text: string);33 procedure Add(Text: string; Group: string = ''); 34 34 procedure WriteToFile(Text: string); 35 35 constructor Create(AOwner: TComponent); override; … … 52 52 procedure Register; 53 53 begin 54 RegisterComponents(' Samples', [TDebugLog]);54 RegisterComponents('Common', [TDebugLog]); 55 55 end; 56 56 … … 69 69 end; 70 70 71 procedure TDebugLog.Add( Group: string; Text: string);71 procedure TDebugLog.Add(Text: string; Group: string = ''); 72 72 var 73 73 NewItem: TDebugLogItem; … … 103 103 try 104 104 if ExtractFileDir(FileName) <> '' then 105 ForceDirectories UTF8(ExtractFileDir(FileName));106 if FileExists UTF8(FileName) then LogFile := TFileStream.Create(UTF8Decode(FileName), fmOpenWrite)105 ForceDirectories(ExtractFileDir(FileName)); 106 if FileExists(FileName) then LogFile := TFileStream.Create(UTF8Decode(FileName), fmOpenWrite) 107 107 else LogFile := TFileStream.Create(UTF8Decode(FileName), fmCreate); 108 108 LogFile.Seek(0, soFromEnd); -
trunk/Components/Common/UFindFile.pas
r31 r34 55 55 end; 56 56 57 const 58 {$IFDEF WINDOWS} 59 FilterAll = '*.*'; 60 {$ENDIF} 61 {$IFDEF LINUX} 62 FilterAll = '*'; 63 {$ENDIF} 64 57 65 procedure Register; 58 66 … … 64 72 procedure Register; 65 73 begin 66 RegisterComponents(' Samples', [TFindFile]);74 RegisterComponents('Common', [TFindFile]); 67 75 end; 68 76 … … 71 79 inherited Create(AOwner); 72 80 Path := IncludeTrailingBackslash(UTF8Encode(GetCurrentDir)); 73 FileMask := '*.*';81 FileMask := FilterAll; 74 82 FileAttr := [ffaAnyFile]; 75 83 s := TStringList.Create; … … 127 135 If not InSubFolders then Exit; 128 136 129 if SysUtils.FindFirst(UTF8Decode(inPath + '*.*'), faDirectory, Rec) = 0 then137 if SysUtils.FindFirst(UTF8Decode(inPath + FilterAll), faDirectory, Rec) = 0 then 130 138 try 131 139 repeat -
trunk/Components/Common/UJobProgressView.lfm
r31 r34 14 14 OnDestroy = FormDestroy 15 15 Position = poScreenCenter 16 LCLVersion = '1. 1'16 LCLVersion = '1.6.0.4' 17 17 object PanelOperationsTitle: TPanel 18 18 Left = 0 … … 28 28 object LabelOperation: TLabel 29 29 Left = 8 30 Height = 1 430 Height = 13 31 31 Top = 8 32 Width = 6 732 Width = 66 33 33 Caption = 'Operations:' 34 34 Font.Height = -11 … … 80 80 object LabelEstimatedTimePart: TLabel 81 81 Left = 8 82 Height = 1 482 Height = 13 83 83 Top = -2 84 Width = 7 284 Width = 71 85 85 Caption = 'Estimated time:' 86 86 ParentColor = False … … 132 132 object LabelEstimatedTimeTotal: TLabel 133 133 Left = 8 134 Height = 1 4134 Height = 13 135 135 Top = 0 136 Width = 9 8136 Width = 97 137 137 Caption = 'Total estimated time:' 138 138 ParentColor = False -
trunk/Components/Common/UJobProgressView.lrt
r31 r34 1 T JOBPROGRESSVIEW.LABELOPERATION.CAPTION=Operations:2 T JOBPROGRESSVIEW.LABELESTIMATEDTIMEPART.CAPTION=Estimated time:3 T JOBPROGRESSVIEW.LABELESTIMATEDTIMETOTAL.CAPTION=Total estimated time:1 TFORMJOBPROGRESSVIEW.LABELOPERATION.CAPTION=Operations: 2 TFORMJOBPROGRESSVIEW.LABELESTIMATEDTIMEPART.CAPTION=Estimated time: 3 TFORMJOBPROGRESSVIEW.LABELESTIMATEDTIMETOTAL.CAPTION=Total estimated time: -
trunk/Components/Common/UJobProgressView.pas
r31 r34 111 111 Finished: Boolean; 112 112 FOnJobFinish: TJobProgressViewMethod; 113 FOnOwnerDraw: TNotifyEvent; 114 FOwnerDraw: Boolean; 113 115 FShowDelay: Integer; 114 116 FTerminate: Boolean; … … 116 118 TotalStartTime: TDateTime; 117 119 Log: TStringList; 118 Form: TFormJobProgressView;119 120 procedure SetTerminate(const AValue: Boolean); 120 121 procedure UpdateProgress; … … 122 123 procedure StartJobs; 123 124 procedure UpdateHeight; 125 procedure JobProgressChange(Sender: TObject); 124 126 public 127 Form: TFormJobProgressView; 125 128 Jobs: TObjectList; // TListObject<TJob> 126 129 CurrentJob: TJob; … … 136 139 property Terminate: Boolean read FTerminate write SetTerminate; 137 140 published 141 property OwnerDraw: Boolean read FOwnerDraw write FOwnerDraw; 138 142 property ShowDelay: Integer read FShowDelay write FShowDelay; 139 143 property AutoClose: Boolean read FAutoClose write FAutoClose; 140 144 property OnJobFinish: TJobProgressViewMethod read FOnJobFinish 141 145 write FOnJobFinish; 146 property OnOwnerDraw: TNotifyEvent read FOnOwnerDraw 147 write FOnOwnerDraw; 142 148 end; 143 149 … … 160 166 STotalEstimatedTime = 'Total estimated time: %s'; 161 167 SFinished = 'Finished'; 168 SOperations = 'Operations'; 162 169 163 170 procedure Register; 164 171 begin 165 RegisterComponents(' Samples', [TJobProgressView]);172 RegisterComponents('Common', [TJobProgressView]); 166 173 end; 167 174 … … 196 203 NewJob.Progress.Max := 100; 197 204 NewJob.Progress.Reset; 205 NewJob.Progress.OnChange := JobProgressChange; 198 206 Jobs.Add(NewJob); 199 207 //ReloadJobList; … … 212 220 Terminate := False; 213 221 214 Form.BringToFront;222 if not OwnerDraw then Form.BringToFront; 215 223 216 224 Finished := False; … … 244 252 CurrentJobIndex := I; 245 253 CurrentJob := TJob(Jobs[I]); 254 JobProgressChange(Self); 246 255 StartTime := Now; 247 256 Form.LabelEstimatedTimePart.Caption := Format(SEstimatedTime, ['']); … … 339 348 end; 340 349 350 procedure TJobProgressView.JobProgressChange(Sender: TObject); 351 begin 352 if Assigned(FOnOwnerDraw) then 353 FOnOwnerDraw(Self); 354 end; 355 341 356 procedure TFormJobProgressView.TimerUpdateTimer(Sender: TObject); 342 357 var … … 357 372 if not Visible then begin 358 373 TimerUpdate.Interval := UpdateInterval; 359 Show;374 if not JobProgressView.OwnerDraw then Show; 360 375 end; 361 376 end; … … 509 524 destructor TJobProgressView.Destroy; 510 525 begin 511 Log.Free;512 Jobs.Free;513 inherited Destroy;526 FreeAndNil(Log); 527 FreeAndNil(Jobs); 528 inherited; 514 529 end; 515 530 … … 519 534 FLock.Acquire; 520 535 FMax := AValue; 536 if FMax < 1 then FMax := 1; 521 537 if FValue >= FMax then FValue := FMax; 522 538 finally … … 610 626 begin 611 627 Progress.Free; 612 inherited Destroy;628 inherited; 613 629 end; 614 630 -
trunk/Components/Common/ULastOpenedList.pas
r31 r34 6 6 7 7 uses 8 Classes, SysUtils, Registry, URegistry, Menus ;8 Classes, SysUtils, Registry, URegistry, Menus, XMLConf; 9 9 10 10 type … … 18 18 procedure SetMaxCount(AValue: Integer); 19 19 procedure LimitMaxCount; 20 procedure ItemsChange(Sender: TObject); 21 procedure DoChange; 20 22 public 21 23 Items: TStringList; … … 25 27 procedure LoadFromRegistry(Context: TRegistryContext); 26 28 procedure SaveToRegistry(Context: TRegistryContext); 29 procedure LoadFromXMLConfig(XMLConfig: TXMLConfig; Path: string); 30 procedure SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 27 31 procedure AddItem(FileName: string); 28 32 published … … 38 42 procedure Register; 39 43 begin 40 RegisterComponents(' Samples', [TLastOpenedList]);44 RegisterComponents('Common', [TLastOpenedList]); 41 45 end; 42 46 … … 58 62 end; 59 63 64 procedure TLastOpenedList.ItemsChange(Sender: TObject); 65 begin 66 DoChange; 67 end; 68 69 procedure TLastOpenedList.DoChange; 70 begin 71 if Assigned(FOnChange) then 72 FOnChange(Self); 73 end; 74 60 75 constructor TLastOpenedList.Create(AOwner: TComponent); 61 76 begin 62 77 inherited; 63 78 Items := TStringList.Create; 79 Items.OnChange := ItemsChange; 64 80 MaxCount := 10; 65 81 end; … … 129 145 end; 130 146 147 procedure TLastOpenedList.LoadFromXMLConfig(XMLConfig: TXMLConfig; Path: string 148 ); 149 var 150 I: Integer; 151 Value: string; 152 Count: Integer; 153 begin 154 with XMLConfig do begin 155 Count := GetValue(Path + '/Count', 0); 156 if Count > MaxCount then Count := MaxCount; 157 Items.Clear; 158 for I := 0 to Count - 1 do begin 159 Value := GetValue(Path + '/File' + IntToStr(I), ''); 160 if Trim(Value) <> '' then Items.Add(Value); 161 end; 162 if Assigned(FOnChange) then 163 FOnChange(Self); 164 end; 165 end; 166 167 procedure TLastOpenedList.SaveToXMLConfig(XMLConfig: TXMLConfig; Path: string); 168 var 169 I: Integer; 170 begin 171 with XMLConfig do begin 172 SetValue(Path + '/Count', Items.Count); 173 for I := 0 to Items.Count - 1 do 174 SetValue(Path + '/File' + IntToStr(I), Items[I]); 175 Flush; 176 end; 177 end; 178 131 179 procedure TLastOpenedList.AddItem(FileName:string); 132 180 begin … … 134 182 Items.Insert(0, FileName); 135 183 LimitMaxCount; 136 if Assigned(FOnChange) then 137 FOnChange(Self); 184 DoChange; 138 185 end; 139 186 -
trunk/Components/Common/URegistry.pas
r31 r34 17 17 rrKeyDynData = HKEY($80000006)); 18 18 19 { TRegistryContext } 20 19 21 TRegistryContext = record 20 22 RootKey: HKEY; 21 23 Key: string; 24 class operator Equal(A, B: TRegistryContext): Boolean; 22 25 end; 23 26 … … 26 29 TRegistryEx = class(TRegistry) 27 30 private 31 function GetCurrentContext: TRegistryContext; 32 procedure SetCurrentContext(AValue: TRegistryContext); 28 33 public 29 34 function ReadBoolWithDefault(const Name: string; … … 35 40 function DeleteKeyRecursive(const Key: string): Boolean; 36 41 function OpenKey(const Key: string; CanCreate: Boolean): Boolean; 42 property CurrentContext: TRegistryContext read GetCurrentContext write SetCurrentContext; 37 43 end; 38 44 … … 46 52 Result.RootKey := RootKey; 47 53 Result.Key := Key; 54 end; 55 56 { TRegistryContext } 57 58 class operator TRegistryContext.Equal(A, B: TRegistryContext): Boolean; 59 begin 60 Result := (A.Key = B.Key) and (A.RootKey = B.RootKey); 48 61 end; 49 62 … … 106 119 end; 107 120 121 function TRegistryEx.GetCurrentContext: TRegistryContext; 122 begin 123 Result.Key := CurrentPath; 124 Result.RootKey := RootKey; 125 end; 126 127 procedure TRegistryEx.SetCurrentContext(AValue: TRegistryContext); 128 begin 129 RootKey := AValue.RootKey; 130 OpenKey(AValue.Key, True); 131 end; 132 108 133 function TRegistryEx.ReadBoolWithDefault(const Name: string; 109 134 DefaultValue: Boolean): Boolean; -
trunk/Components/Common/UResetableThread.pas
r31 r34 104 104 105 105 procedure TResetableThread.WaitForStart; 106 var107 WaitResult: TWaitResult;106 //var 107 // WaitResult: TWaitResult; 108 108 begin 109 109 //try … … 127 127 128 128 procedure TResetableThread.WaitForStop; 129 var130 WaitState: TWaitResult;129 //var 130 // WaitState: TWaitResult; 131 131 begin 132 132 try -
trunk/Components/Common/UURI.pas
r31 r34 326 326 Drive := Drive + DriveSeparator; 327 327 end else Drive := ''; 328 Directory.AsString := AValue; 328 if (Drive <> '') and (AValue = '') then 329 Directory.AsString := Directory.DirSeparator 330 else Directory.AsString := AValue; 329 331 end; 330 332 -
trunk/Components/Common/UXMLUtils.pas
r31 r34 7 7 uses 8 8 {$IFDEF WINDOWS}Windows,{$ENDIF} 9 Classes, SysUtils, DateUtils ;9 Classes, SysUtils, DateUtils, XMLRead, XMLWrite, DOM; 10 10 11 11 function XMLTimeToDateTime(XMLDateTime: string): TDateTime; 12 12 function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString; 13 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 14 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 15 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 16 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 17 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 18 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 19 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 20 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 21 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 22 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime): TDateTime; 13 23 14 24 … … 66 76 Minute: Integer; 67 77 Second: Integer; 78 SecondFraction: Double; 68 79 Millisecond: Integer; 69 80 begin … … 88 99 if Pos('Z', XMLDateTime) > 0 then 89 100 LeftCutString(XMLDateTime, Part, 'Z'); 90 Millisecond := StrToInt(Part); 101 SecondFraction := StrToFloat('0' + DecimalSeparator + Part); 102 Millisecond := Trunc(SecondFraction * 1000); 91 103 end else begin 92 104 if Pos('+', XMLDateTime) > 0 then … … 123 135 end; 124 136 137 procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer); 138 var 139 NewNode: TDOMNode; 140 begin 141 NewNode := Node.OwnerDocument.CreateElement(Name); 142 NewNode.TextContent := IntToStr(Value); 143 Node.AppendChild(NewNode); 144 end; 145 146 procedure WriteInt64(Node: TDOMNode; Name: string; Value: Int64); 147 var 148 NewNode: TDOMNode; 149 begin 150 NewNode := Node.OwnerDocument.CreateElement(Name); 151 NewNode.TextContent := IntToStr(Value); 152 Node.AppendChild(NewNode); 153 end; 154 155 procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean); 156 var 157 NewNode: TDOMNode; 158 begin 159 NewNode := Node.OwnerDocument.CreateElement(Name); 160 NewNode.TextContent := BoolToStr(Value); 161 Node.AppendChild(NewNode); 162 end; 163 164 procedure WriteString(Node: TDOMNode; Name: string; Value: string); 165 var 166 NewNode: TDOMNode; 167 begin 168 NewNode := Node.OwnerDocument.CreateElement(Name); 169 NewNode.TextContent := Value; 170 Node.AppendChild(NewNode); 171 end; 172 173 procedure WriteDateTime(Node: TDOMNode; Name: string; Value: TDateTime); 174 var 175 NewNode: TDOMNode; 176 begin 177 NewNode := Node.OwnerDocument.CreateElement(Name); 178 NewNode.TextContent := DateTimeToXMLTime(Value); 179 Node.AppendChild(NewNode); 180 end; 181 182 function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer; 183 var 184 NewNode: TDOMNode; 185 begin 186 Result := DefaultValue; 187 NewNode := Node.FindNode(Name); 188 if Assigned(NewNode) then 189 Result := StrToInt(NewNode.TextContent); 190 end; 191 192 function ReadInt64(Node: TDOMNode; Name: string; DefaultValue: Int64): Int64; 193 var 194 NewNode: TDOMNode; 195 begin 196 Result := DefaultValue; 197 NewNode := Node.FindNode(Name); 198 if Assigned(NewNode) then 199 Result := StrToInt64(NewNode.TextContent); 200 end; 201 202 function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean; 203 var 204 NewNode: TDOMNode; 205 begin 206 Result := DefaultValue; 207 NewNode := Node.FindNode(Name); 208 if Assigned(NewNode) then 209 Result := StrToBool(NewNode.TextContent); 210 end; 211 212 function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string; 213 var 214 NewNode: TDOMNode; 215 begin 216 Result := DefaultValue; 217 NewNode := Node.FindNode(Name); 218 if Assigned(NewNode) then 219 Result := NewNode.TextContent; 220 end; 221 222 function ReadDateTime(Node: TDOMNode; Name: string; DefaultValue: TDateTime 223 ): TDateTime; 224 var 225 NewNode: TDOMNode; 226 begin 227 Result := DefaultValue; 228 NewNode := Node.FindNode(Name); 229 if Assigned(NewNode) then 230 Result := XMLTimeToDateTime(NewNode.TextContent); 231 end; 232 125 233 end. 126 234
Note:
See TracChangeset
for help on using the changeset viewer.