Four simple bitwise operations as Pascal functions.
function GetBit(const Val: DWord; const BitVal: Byte): Boolean;
begin
Result := (Val and (1 shl BitVal)) <> 0;
end;
function SetBit(const Val: DWord; const BitVal: Byte): DWord;
begin
Result := Val or (1 shl BitVal);
end;
function EnableBit(const Val: DWord; const BitVal: Byte; const SetOn: Boolean): DWord;
begin
Result := (Val or (1 shl BitVal)) xor (Integer(not SetOn) shl BitVal);
end;
function ClearBit(const Val: DWord; const BitVal: Byte): DWord;
begin
Result := Val and not (1 shl BitVal);
end;