📄 dlgietool.cpp
字号:
// DlgIETool.cpp : implementation file
//
#include "stdafx.h"
#include "LeoBlock2004.h"
#include "DlgIETool.h"
#include "LRegistry.h"
#include "FileInfo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgIETool dialog
CDlgIETool::CDlgIETool(CWnd* pParent /*=NULL*/)
: CDialog (CDlgIETool::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgIETool)
//}}AFX_DATA_INIT
}
void CDlgIETool::DoDataExchange(CDataExchange* pDX)
{
CDialog ::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgIETool)
DDX_Control(pDX, IDOK, m_buOk);
DDX_Control(pDX, IDCANCEL, m_buCancel);
DDX_Control(pDX, IDC_BUTTOND_DEL, m_buDel);
DDX_Control(pDX, IDC_BUTTON1, m_buButton1);
DDX_Control(pDX, IDC_BUTTON_HOST_PAGE, m_buHostHtml);
DDX_Control(pDX, IDC_LIST2, m_nRuns);
DDX_Control(pDX, IDC_LIST1, m_nExtensions);
DDX_Control(pDX, IDC_EDIT_HOST_PAGE, m_eIEHostPage);
DDX_Control(pDX, IDC_EDIT_Title, m_eIEWinTitle);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgIETool, CDialog )
//{{AFX_MSG_MAP(CDlgIETool)
ON_BN_CLICKED(IDC_BUTTON_HOST_PAGE, OnButtonResHostPage)
ON_BN_CLICKED(IDC_BUTTOND_DEL, OnButtondDelExtionsions)
ON_BN_CLICKED(IDC_BUTTON1, OnButtonDelRun)
ON_WM_CTLCOLOR()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgIETool message handlers
BOOL CDlgIETool::OnInitDialog()
{
CDialog ::OnInitDialog();
// TODO: Add extra initialization here
//CButtonEx Initialization
//------------
HKEY nKeyRoot=HKEY_LOCAL_MACHINE;
LPSTR nSubKey="Software\\Microsoft\\Internet Explorer\\Main";
CLRegistry nRegistry;
//获取IE标题
do {
if(!nRegistry.Open(nKeyRoot,nSubKey))
break;
LPCTSTR nSzKey="Window Title";
CString nSzValue;
if(nRegistry.VerifyValue(nSzKey))
{
nRegistry.Read(nSzKey,nSzValue);
m_eIEWinTitle.SetWindowText((LPCTSTR)nSzValue);
}
nRegistry.Close();
break;
}while (false);
//nKeyRoot=HKEY_USERS;
//nSubKey=".DEFAULT\\SoftWare\\Microsoft\\Internet Explorer";
nKeyRoot=HKEY_CURRENT_USER;
nSubKey="Software\\Microsoft\\Internet Explorer";
nKeyRoot=HKEY_CURRENT_USER;
nSubKey="Software\\Microsoft\\Internet Explorer\\Main";
//获取IE主页
do {
if(!nRegistry.Open(nKeyRoot,nSubKey))
break;
LPCTSTR nSzKey="Start Page";
CString nSzValue;
if(nRegistry.VerifyValue(nSzKey))
{
nRegistry.Read(nSzKey,nSzValue);
m_eIEHostPage.SetWindowText((LPCTSTR)nSzValue);
}
nRegistry.Close();
break;
}while (false);
//*********************************
//加入列表表头
//向m_nExtensions列表中加入项目
LV_COLUMN nlistColumn;
nlistColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
nlistColumn.fmt=LVCFMT_LEFT;
LPTSTR npszText[2];
npszText[0]="按钮名子";
npszText[1]="CLSID";
for(int i=0;i<2;i++)
{
nlistColumn.cx=100*(i+1);
nlistColumn.iSubItem=i;
nlistColumn.pszText=npszText[i];
m_nExtensions.InsertColumn(i,&nlistColumn);
}
//向m_nRuns列表中加入项目
npszText[0]="程序名";
npszText[1]="路径";
for(i=0;i<2;i++)
{
nlistColumn.cx=110*(i+1+i);
nlistColumn.iSubItem=i;
nlistColumn.pszText=npszText[i];
m_nRuns.InsertColumn(i,&nlistColumn);
}
//取得IE工具条按钮
nKeyRoot=HKEY_LOCAL_MACHINE;
nSubKey="Software\\Microsoft\\Internet Explorer\\Extensions";
do{
if(!nRegistry.Open(nKeyRoot,nSubKey))
break;
CString nsKey; //查询主键
DWORD nIndex=0; //查询主键索引
CLRegistry nsRegistry;
int nindex=0;
while(nRegistry.EnumKey(nsKey,nIndex))
{
CString csSubKey; //新主键值
csSubKey.Format("%s\\",nSubKey);
csSubKey+=nsKey;
if(nsRegistry.Open(nKeyRoot,(LPCTSTR)csSubKey))
{
CString nsValue; //键值
if(nsRegistry.Read("ButtonText",nsValue))
{
if(nsValue!="@shdoclc.dll,-866")
{
//向列表项中加入项目
m_nExtensions.InsertItem(nindex,(LPCTSTR)nsValue);
m_nExtensions.SetItemText(nindex,1,(LPCTSTR)nsKey);
nindex++;
}
}
else
{
if(nsRegistry.Read("MenuText",nsValue))
{
if(nsValue!="@shdoclc.dll,-866")
{
//向列表项中加入项目
m_nExtensions.InsertItem(nindex,(LPCTSTR)nsValue);
m_nExtensions.SetItemText(nindex,1,(LPCTSTR)nsKey);
nindex++;
}
}
}
}
nsRegistry.Close();
nIndex++;
}
nRegistry.Close();
break;
}while (false);
//取得Windows RUNS程序
nKeyRoot=HKEY_LOCAL_MACHINE;
nSubKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
if(nRegistry.Open(nKeyRoot,nSubKey))
{
DWORD nIndex=0;
int nindex=0;
CString ncsKey,ncsValue;
while(nRegistry.EnumValueA(ncsKey,ncsValue,nIndex))
{
nRegistry.Read(ncsKey,ncsValue);
if(!ncsKey.IsEmpty())
{
m_nRuns.InsertItem(nindex,(LPCTSTR)ncsKey);
m_nRuns.SetItemText(nindex,1,(LPCTSTR)ncsValue);
nindex++;
ncsKey="";
ncsValue="";
}
nIndex++;
}
nRegistry.Close();
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgIETool::OnButtonResHostPage()
{
// TODO: Add your control notification handler code here
HKEY nKeyRoot=HKEY_LOCAL_MACHINE;
LPSTR nSubKey="Software\\Microsoft\\Internet Explorer\\Main";
CLRegistry nRegistry;
//取得Window系统目录
LPTSTR nDir=new TCHAR [MAX_PATH];
GetSystemDirectory(nDir,MAX_PATH);
CString nSzValue;
nSzValue.Format("%s\\blank.htm",nDir);
delete [] nDir;
//恢复IE默认的网页HKEY_LOCAL_MACHINE
do {
UpdateData();
//恢复IE的HKEY_LOCAL_MACHINE项
if(!nRegistry.Open(nKeyRoot,nSubKey))
break;
//IE空白网页
LPCTSTR nSzKey="Local Page";
LPCTSTR nValue="";
nRegistry.Write(nSzKey,(LPCTSTR)nSzValue);
//IE搜索网页
nSzKey="Search Page";
nValue="http://www.microsoft.com/isapi/redir.dll?prd=ie&ar=iesearch";
nRegistry.Write(nSzKey,nValue);
//IE开始网页
nSzKey="Start Page";
nValue="http://www.microsoft.com/isapi/redir.dll?prd={SUB_PRD}&clcid={SUB_CLSID}&pver={SUB_PVER}&ar=home";
nRegistry.Write(nSzKey,nValue);
//IE默认网页
nSzKey="Default_Page_URL";
nValue="http://www.microsoft.com/windows/ie_intl/cn/start/";
nRegistry.Write(nSzKey,nValue);
//IE默认搜索网页
nSzKey="Default_Search_URL";
nValue="http://www.microsoft.com/isapi/redir.dll?prd=ie&ar=iesearch";
nRegistry.Write(nSzKey,nValue);
//恢复IE的HKEY_CURRENT_USER
nKeyRoot=HKEY_CURRENT_USER;
if(!nRegistry.Open(nKeyRoot,nSubKey))
break;
//IE空白网页
nSzKey="Local Page";
nRegistry.Write(nSzKey,(LPCTSTR)nSzValue);
//IE搜索网页
nSzKey="Search Page";
nValue="http://www.microsoft.com/isapi/redir.dll?prd=ie&ar=iesearch";
nRegistry.Write(nSzKey,nValue);
//IE默认网页***
m_eIEHostPage.SetWindowText("about:blank");
nSzKey="Start Page";
nValue="about:blank";
nRegistry.Write(nSzKey,nValue);
UpdateData(FALSE);
nRegistry.Close();
break;
} while(false);
}
void CDlgIETool::ButtonDelWebConnection()
{
// TODO: Add your control notification handler code here
//解除其它浏览器与网页文件的连接
/*#define MAX_REGLTYPES 4
LPTSTR nSubKey[MAX_REGLTYPES];
int nrTypes[MAX_REGLTYPES];
nSubKey[0]="ftp";
nSubKey[1]="http";
nSubKey[2]="https";
nSubKey[3]="htmlfile";
nrTypes[0]=REGL_FTP;
nrTypes[1]=REGL_HTTP;
nrTypes[2]=REGL_HTTPS;
nrTypes[3]=REGL_HTMLFILE;
for(int i=0;i<MAX_REGLTYPES;i++)
CreateWebShell(nSubKey[i],(RTypes)nrTypes[i]);*/
}
BOOL CDlgIETool::CreateWebShell(LPTSTR nKey,enum RTypes rTypes)
{
/*CLRegistry nRegistry;
HKEY nKeyRoot=HKEY_CLASSES_ROOT;
CString nStr;
LPCTSTR nSubKey; //键名
LPCTSTR nValue; //键值
//取得Window系统目录
CString nSzValue; //Window系统目录
LPTSTR nDir=new TCHAR [MAX_PATH];
GetSystemDirectory(nDir,MAX_PATH);
//取得系统Program Files路径
CString strProPath;//Program Files路径
LPCTSTR nsProPath;
HKEY nTempRoot=HKEY_LOCAL_MACHINE;
LPCTSTR nTempKey="Software\\Microsoft\\Windows\\CurrentVersion";
LPCTSTR nTempSubKey="ProgramFilesDir";
CString nTempPath;
nRegistry.Open(nTempRoot,nTempKey);
nRegistry.Read(nTempSubKey,nTempPath);
nRegistry.Close();
nTempPath=nTempPath.Left(1);
nsProPath=(LPCTSTR)nTempPath;
switch(rTypes)
{
case REGL_FTP:
{
nSzValue.Format("%s\\url.dll,0",nDir);
strProPath.Format("\"%s:\\PROGRA~1\\INTERN~1\\iexplore.exe\" %%1",nsProPath);
}
break;
case REGL_HTTP:
{
nSzValue.Format("%s\\url.dll,0",nDir);
strProPath.Format("\"%s:\\PROGRA~1\\INTERN~1\\iexplore.exe\" -nohome",nsProPath);
}
break;
case REGL_HTTPS:
{
nSzValue.Format("%s\\url.dll,0",nDir);
strProPath.Format("\"%s:\\PROGRA~1\\INTERN~1\\iexplore.exe\" -nohome",nsProPath);
}
break;
case REGL_HTMLFILE:
{
nSzValue.Format("%s:\\PROGRA~1\\INTERN~1\\iexplore.exe,1",nsProPath);
strProPath.Format("\"%s:\\PROGRA~1\\INTERN~1\\iexplore.exe\" -nohome",nsProPath);
}
break;
default:
break;
}
do{
//设IE图标
nStr.Format("%s",nKey);
nStr+="\\DefaultIcon";
if(nRegistry.Open(nKeyRoot,(LPCTSTR)nStr))
{
nSubKey="(默认)";
//nValue="C:\WINDOWS\SYSTEM\url.dll,0"
nRegistry.DeleteValue(nSubKey);
//nRegistry.Write(nSubKey,(LPCTSTR)nSzValue);
nStr="";
nRegistry.Close();
}
//设置默认的浏览器为IE
nStr.Format("%s",nKey);
nStr+="\\shell\\open\\command";
if(nRegistry.Open(nKeyRoot,(LPCTSTR)nStr))
{
nSubKey="(默认)";
//nValue=""C:\PROGRA~1\INTERN~1\iexplore.exe\" %1";
nRegistry.DeleteValue(nSubKey);
//nRegistry.Write(nSubKey,(LPCTSTR)strProPath);
nStr="";
nRegistry.Close();
}
//设置默认的浏览器应用程序为IE
nStr.Format("%s",nKey);
nStr+="\\shell\\open\\ddeexec\\Application";
if(nRegistry.Open(nKeyRoot,(LPCTSTR)nStr))
{
nSubKey="(默认)";
nValue="IExplore";
nRegistry.DeleteValue(nSubKey);
// nRegistry.Write(nSubKey,nValue);
nStr="";
nRegistry.Close();
}
break;
} while(false);
delete [] nDir;*/
return TRUE;
}
void CDlgIETool::OnOK()
{
// TODO: Add extra validation here
UpdateData();
//更新下载路径************
CLRegistry nRegistry;
//HKEY nKeyRoot=HKEY_USERS;
//LPCTSTR nSubKey=".DEFAULT\\SoftWare\\Microsoft\\Internet Explorer";
HKEY nKeyRoot=HKEY_CURRENT_USER;
LPCTSTR nSubKey="Software\\Microsoft\\Internet Explorer";
CString nstrValue;
//更新IE主页****************
nKeyRoot=HKEY_CURRENT_USER;
nSubKey="Software\\Microsoft\\Internet Explorer\\Main";
LPTSTR nSzKey="Start Page";
m_eIEHostPage.GetWindowText(nstrValue);
if(!nstrValue.IsEmpty())
{
nRegistry.Open(nKeyRoot,nSubKey);
nRegistry.Write(nSzKey,(LPCTSTR)nstrValue);
nstrValue="";
nRegistry.Close();
}
//更新IE标题****************
nKeyRoot=HKEY_LOCAL_MACHINE;
nSubKey="SOFTWARE\\Microsoft\\Internet Explorer\\Main";
nSzKey="Window Title";
m_eIEWinTitle.GetWindowText(nstrValue);
if(!nstrValue.IsEmpty())
{
nRegistry.Open(nKeyRoot,nSubKey);
nRegistry.Write(nSzKey,(LPCTSTR)nstrValue);
nstrValue="";
nRegistry.Close();
}
CDialog ::OnOK();
}
void CDlgIETool::OnButtondDelExtionsions()
{
// TODO: Add your control notification handler code here
//取得列表项
CString ncsText; //取得列表项的字符串GUID
int nindex=m_nExtensions.GetNextItem(-1,LVNI_SELECTED);
ncsText=m_nExtensions.GetItemText(nindex,1);
if(!ncsText.IsEmpty())
{
int nChoice=MessageBox("要删除选中的项?","Leo",MB_YESNO|MB_ICONQUESTION);
if(nChoice==IDYES)
{
//删除注册表,列表项
HKEY nRootKey=HKEY_LOCAL_MACHINE;
LPSTR nsSubKey="Software\\Microsoft\\Internet Explorer\\Extensions";
CString ncsKey;
CLRegistry nRegistry;
if(nRegistry.Open(nRootKey,nsSubKey))
{
ncsKey.Format("%s\\",nsSubKey);
ncsKey+=ncsText;
nRegistry.DeleteValueKey(nRootKey,(LPCTSTR)ncsKey);
m_nExtensions.DeleteItem(nindex);
}
}
}
}
void CDlgIETool::OnButtonDelRun()
{
// TODO: Add your control notification handler code here
//取得列表项
CString ncsText; //取得列表项的字符串GUID
int nindex=m_nRuns.GetNextItem(-1,LVNI_SELECTED);
ncsText=m_nRuns.GetItemText(nindex,0);
if(!ncsText.IsEmpty())
{
int nChoice=MessageBox("要删除选中的项?","Leo",MB_YESNO|MB_ICONQUESTION);
if(nChoice==IDYES)
{
//删除注册表,列表项
HKEY nRootKey=HKEY_LOCAL_MACHINE;
LPSTR nsSubKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run";
CLRegistry nRegistry;
if(nRegistry.Open(nRootKey,nsSubKey))
{
nRegistry.DeleteValue(ncsText);
m_nRuns.DeleteItem(nindex);
}
nRegistry.Close();
}
}
}
HBRUSH CDlgIETool::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog ::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
// TODO: Return a different brush if the default is not desired
return hbr;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -