Changeset 434 for Common/UCommon.pas


Ignore:
Timestamp:
Nov 19, 2012, 2:31:00 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Confused TRegistryEx property Context with Context parameter in some methods.
  • Fixed: TURI path was not properly handled in case of file in root directory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Common/UCommon.pas

    r404 r434  
    4848function LoggedOnUserNameEx(Format: TUserNameFormat): string;
    4949function SplitString(var Text: string; Count: Word): string;
     50function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
    5051function GetBit(Variable: QWord; Index: Byte): Boolean;
     52procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload;
    5153procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload;
    5254procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload;
     
    336338end;
    337339
     340function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer;
     341var
     342  I: Integer;
     343begin
     344  Result := 0;
     345  for I := 0 to MaxIndex - 1 do
     346    if ((Variable shr I) and 1) = 1 then Inc(Result);
     347end;
     348
    338349function GetBit(Variable:QWord;Index:Byte):Boolean;
    339350begin
     
    341352end;
    342353
     354procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean);
     355begin
     356  Variable := (Variable and ((1 shl Index) xor High(QWord))) or (Int64(State) shl Index);
     357end;
     358
    343359procedure SetBit(var Variable:QWord;Index:Byte;State:Boolean); overload;
    344360begin
    345   Variable := (Variable and ((1 shl Index) xor QWord($ffffffffffffffff))) or (QWord(State) shl Index);
     361  Variable := (Variable and ((1 shl Index) xor High(QWord))) or (QWord(State) shl Index);
    346362end;
    347363
    348364procedure SetBit(var Variable:Cardinal;Index:Byte;State:Boolean); overload;
    349365begin
    350   Variable := (Variable and ((1 shl Index) xor Cardinal($ffffffff))) or (Cardinal(State) shl Index);
     366  Variable := (Variable and ((1 shl Index) xor High(Cardinal))) or (Cardinal(State) shl Index);
    351367end;
    352368
    353369procedure SetBit(var Variable:Word;Index:Byte;State:Boolean); overload;
    354370begin
    355   Variable := (Variable and ((1 shl Index) xor Word($ffff))) or (Word(State) shl Index);
     371  Variable := (Variable and ((1 shl Index) xor High(Word))) or (Word(State) shl Index);
    356372end;
    357373
Note: See TracChangeset for help on using the changeset viewer.