📄 antinags.dpr
字号:
{==============================================================================
软件名称:Anti ActiveX nags v1.52 Build 0717
软件功能:
在浏览网页时,经常会弹出各类要求您认证的对话框(如“3721网络实名”等),
碰得多了实在有够烦的。本软件专为免除这些恼人的对话框而设计,您只需选中想
屏蔽的项目,然后点击【应用】按钮就能达到免疫的目的。
软件作者:xnbyte
官方网站:http://www.xnbyte.com
版权说明:免费开源绿色软件,传播时请保留压缩包的完整性及本版权信息,谢谢。
==============================================================================}
program Antinags;
uses
Windows, Messages, CommCtrl, MiniReg, StrList, ShellAPI;
{$R Antinags.res}
const
IDI_MAINICON =101;
IDC_BUTTON_ABOUT =1001;
IDC_BUTTON_HELP =1002;
IDC_BUTTON_CUSTOMIZE =1003;
IDC_BUTTON_DISSELECT =1004;
IDC_BUTTON_SELECTALL =1005;
IDC_BUTTON_APPLY =1006;
IDC_BUTTON_EXIT =1007;
IDC_BUTTON_OK =2001;
IDC_BUTTON_HELPOK =3001;
IDC_STATUS =1101;
szMainWin ='MainWin';
szAboutDlg ='About';
szHelpDlg ='Help';
var
hListView: HWND;
hFontBig: HFONT;
hwndStatus: DWORD;
//直接给出IntToStr函数,避免引用SysUtils单元,以减小最终编译文件的大小
function IntToStr(const i: integer): string;
begin
Str(i, Result);
end;
//“帮助”对话框的处理
function HelpProc(HelpWnd: hWnd; Msg, wParam: WORD; lParam: Integer): Integer; stdcall;
var
HelpBtn: WORD;
begin
Case Msg of
WM_CLOSE:
EndDialog(HelpWnd, 0);
WM_COMMAND:
begin
HelpBtn := wParam;
if HelpBtn = IDC_BUTTON_HELPOK or IDOK then
EndDialog(HelpWnd, 0);
end;
end;
Result := 0;
end;
//“关于”对话框的处理
function AboutProc(AboutWnd: hWnd; Msg, wParam: WORD; lParam: Integer): Integer; stdcall;
var
AboutBtn: WORD;
PaintStruct: TPaintStruct;
PaintDC: HDC;
begin
case Msg of
WM_CLOSE:
EndDialog(AboutWnd, 0);
WM_PAINT:
begin
PaintDC := BeginPaint(AboutWnd, PaintStruct);
SetBkColor(PaintDC, GetSysColor(COLOR_BTNFACE));
TextOut(PaintDC, 96, 15, PChar('Anti ActiveX nags v1.52 Build 0717 '), 34);
SetTextColor(PaintDC, RGB($0, $0, $FF));
TextOut(PaintDC, 160, 39, PChar('xnbyte '), 6);
TextOut(PaintDC, 160, 58, PChar('http://www.xnbyte.com '), 21);
SetTextColor(PaintDC, RGB($63, $75, $9c));
TextOut(PaintDC, 144, 184, PChar('<--- '), 4);
EndPaint(AboutWnd, PaintStruct);
end;
WM_COMMAND:
begin
AboutBtn := wParam;
if AboutBtn = IDC_BUTTON_OK or IDOK then
EndDialog(AboutWnd, 0);
end;
end;
Result:=0;
end;
//函数,用于从"Antinags.ini"文件中读取数据
function GetStrItem(SourStr: string; Border: Char; Index: integer): string;
var
TempStr: string;
I: integer;
begin
TempStr := SourStr;
if Pos(Border, SourStr)=0 then
Result := ''
else
begin
try
for I := 1 to Index - 1 do
begin
if Pos(Border, TempStr) = 0 then
begin
Result := '';
Exit;
end;
Delete(TempStr, 1, Pos(Border, TempStr));
end;
except
Result := '';
Exit;
end;
if Pos(Border, TempStr)=0 then
Result := TempStr
else
Result := Copy(TempStr, 1, Pos(Border, TempStr) - 1);
end;
end;
//创建列表框Listview
procedure CreateColumns(const hListView: HWND; Ticked: integer; Total: integer);
var
LVColumn: TLVColumn;
begin
LVColumn.mask := LVCF_TEXT or LVCF_WIDTH;
LVColumn.pszText := PChar('名称(已屏蔽'+IntToStr(Ticked)+'项,共'+IntToStr(Total)+'项)');
LVColumn.cx := 169;
ListView_InsertColumn(hListView, 0, LVColumn);
LVColumn.mask := LVColumn.mask;
LVColumn.pszText := 'CLSID';
LVColumn.cx := 250;
ListView_InsertColumn(hListView, 1, LVColumn);
end;
//主函数
function MainProc(hWindow: hWnd; Msg, wParam: WORD; lParam: Integer): Integer; stdcall;
var
Getlist: TStrList;
rec: TRect;
LVItem: TLVItem;
buffer: array[0..255] of Char;
CaptionIcon, Btn: DWORD;//标题栏图标
StatusWidth, ticknum: integer;
num: byte;
b: Cardinal;
OpenStatus: boolean;
begin
Getlist := TStrList.Create;
Getlist.LoadFromFile('Antinags.ini');
GetClientRect(hWindow, rec);//获取主窗口的宽度,从而确定状态栏宽度
StatusWidth := rec.Right-rec.Left;
case Msg of
WM_CLOSE:
begin
AnimateWindow(hWindow, 500, AW_HIDE or AW_BLEND);//添加关闭主窗口时的渐隐特效
EndDialog(hWindow, 0);
end;
WM_INITDIALOG:
begin
CaptionIcon:=LoadIcon(hInstance, PChar(IDI_MAINICON));
SendMessage(hWindow, WM_SETICON, ICON_SMALL, CaptionIcon);//设置标题栏图标
hWndStatus := CreateStatusWindow(WS_CHILD or WS_VISIBLE or SBT_TOOLTIPS or SBT_RTLREADING,
nil, hWindow, IDC_STATUS);
SendMessage(hWndStatus, SB_SETPARTS, 1, Integer(@StatusWidth));//这里的“1”表示只设置一栏
buffer:=' 100% freeware + 0% spyware, CoDe bY xnbyte with Win32API + Borland Delphi 7';
SendMessage(hWndStatus, SB_SETTEXT, 0, Integer(@buffer));
hFontBig:=CreateFont(-12, 0, 0, 0, 0, 0, 0, 0, OUT_TT_PRECIS, 0, 0, 0, VARIABLE_PITCH or FF_ROMAN, '宋体');
hListView:= CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, nil,
WS_VISIBLE or WS_CHILD or LVS_REPORT or LVS_EDITLABELS or
LVS_SHOWSELALWAYS{ or LVS_SORTASCENDING}, 0, 0, 100, 100, hWindow, 0, hInstance, nil);//创建Listview
SendMessage(hListView, LVM_SETEXTENDEDLISTVIEWSTYLE, 0,
LVS_EX_HEADERDRAGDROP or LVS_EX_FULLROWSELECT or LVS_EX_CHECKBOXES or LVS_EX_GRIDLINES);//设置Listview外观
SendMessage(hListView, WM_SETFONT, hFontBig, 0);
MoveWindow(hListView, 18, 66, 456, 234, true);//指定ListView的宽高及坐标
ticknum := 0;
for num := 0 to Getlist.Count-1 do
begin
RegGetDword(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\'+GetStrItem(Getlist[num],'=',1)+'\Compatibility Flags',b);
if b=1024 then
ticknum:=ticknum+1;
end;
CreateColumns(hListView, ticknum, Getlist.Count);
//以下开始载入ListView内容项目
OpenStatus := Getlist.LoadFromFile('Antinags.ini');
if OpenStatus then//如果正确找到“Antinags.ini”文件
for num := 0 to Getlist.Count-1 do
begin
LVItem.mask := LVIF_TEXT;
LVItem.iItem := num;
LVItem.iSubItem := 0;
LVItem.pszText := pointer(GetStrItem(Getlist[num], '=', 2));
ListView_InsertItem(hListView, LVItem);
LVItem.mask := LVIF_TEXT;
LVItem.iSubItem := 1;
LVItem.pszText := pointer(GetStrItem(Getlist[num], '=', 1));
ListView_SetItem(hListView, LVItem);
RegGetDword(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\'+GetStrItem(Getlist[num],'=',1)+'\Compatibility Flags', b);
if b=1024 then
ListView_SetCheckState(hListView, num, true);
end
else
begin
MessageBox(hWindow, '无法载入数据文件“Antinags.ini”,请确定它是否和本软件在同一目录下。', 'Anti ActiveX nags v1.51', MB_OK or MB_ICONWARNING);
end;
end;
WM_LBUTTONDOWN://点击任意位置可实现拖动
begin
SetCursor(LoadCursor(0, IDC_HAND));//设置光标
SendMessage(hWindow, WM_NCLBUTTONDOWN, HTCAPTION, lParam);
end;
WM_COMMAND:
begin
Btn:=wParam;
case Btn of
IDC_BUTTON_ABOUT:
DialogBoxParam(hInstance, szAboutDlg, hWindow, @AboutProc, 0);
IDC_BUTTON_HELP:
DialogBoxParam(hInstance, szHelpDlg, hWindow, @HelpProc, 0);
IDC_BUTTON_CUSTOMIZE:
if MessageBox(hWindow, '通过编辑本软件目录下的数据文件 “Antinags.ini” 可以'+#13+#10'自定义要屏蔽的ActiveX控件,是否现在就进行编辑?', '定制确认', MB_ICONQUESTION or MB_YESNO or MB_DEFBUTTON2) = IDYES then
ShellExecute(hWindow, 'open', pchar('Antinags.ini'), nil, nil, SW_SHOWNORMAL);
IDC_BUTTON_EXIT:
SendMessage(hWindow, WM_CLOSE, 0, 0);
IDC_BUTTON_DISSELECT:
begin
for num := 0 to Getlist.Count-1 do
if ListView_GetCheckState(hListView, num)=0 then//如果没有被选中
ListView_SetCheckState(hListView, num, true)//选中它
else
ListView_SetCheckState(hListView, num, false);//不选
end;
IDC_BUTTON_SELECTALL:
begin
for num := 0 to Getlist.Count-1 do
ListView_SetCheckState(hListView, num, true);
end;
IDC_BUTTON_APPLY, IDOK:
begin
for num := 0 to Getlist.Count-1 do
begin
if ListView_GetCheckState(hListView, num)=0 then
RegSetDword(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\'
+GetStrItem(Getlist[num], '=', 1)+'\Compatibility Flags', 0)
else
RegSetDword(HKEY_LOCAL_MACHINE,
'SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\'
+GetStrItem(Getlist[num],'=', 1)+'\Compatibility Flags', 1024);
end;
MessageBox(hWindow, '设置成功,所有被选定的项目已被成功屏蔽。', '提示', MB_OK or MB_ICONINFORMATION);
end;
end;
end;
end;
Getlist.Destroy;
Result := 0;
end;
begin
DialogBoxParam(hInstance, szMainWin, 0, @MainProc, 0);//程序开始处,调用DialogBoxParam创建程序的主对话框
ExitProcess(0); //程序结束处,调用了ExitProcess
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -