📄 xpepssohelpdlg.cpp
字号:
{
KillTimer(1);
m_timer=3000;
SetTimer(1,m_timer,NULL);
}
m_lastTicket=GetTickCount();
}
lValue=100;
if(RegQueryValueEx(hKey,"DownloadUI",NULL,NULL,(LPBYTE)buf,&lValue) ==ERROR_SUCCESS)
AddListString("HKEY_CURRENT_USER段IE下载关联清除失败!");
}
RegCloseKey(hKey);//关闭注册表对象
}
else
AddListString("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Internet Explorer打开失败!");
}
CString CXpepssohelpDlg::GetAppsDir()
{
char tmp[100],user[30];
ULONG c=30;
GetWindowsDirectory(tmp,100);
tmp[3]='\0';
strcat(tmp,"Documents and Settings\\");
GetUserName(user,&c);
strcat(tmp,user);
strcat(tmp,"\\Local Settings\\Apps\\2.0");
return CString(tmp);
}
BOOL CXpepssohelpDlg::DeleteDir(char *pDir)
{
CFileFind tempFind;
char tempFileFind[200];
sprintf(tempFileFind,"%s\\*.*",pDir);
BOOL isExist;
BOOL IsFinded=isExist=(BOOL)tempFind.FindFile(tempFileFind);
if(isExist)
{
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile();
if(!tempFind.IsDots())
{
char foundFileName[200];
strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));
if(tempFind.IsDirectory())
{
char tempDir[200];
sprintf(tempDir,"%s\\%s",pDir,foundFileName);
DeleteDir(tempDir);
}
else
{
char tempFileName[200];
sprintf(tempFileName,"%s\\%s",pDir,foundFileName);
DeleteFile(tempFileName);
}
}
}
tempFind.Close();
if(!RemoveDirectory(pDir))
{
TCHAR pTemp[200];
strcpy(pTemp,"删除目录");
strcat(pTemp,pDir);
strcat(pTemp,"失败!");
AddListString(pTemp);
// ::MessageBox(NULL,pTemp,"警告信息",MB_OK);
return FALSE;
}
}
return TRUE;
}
void CXpepssohelpDlg::AddListString(LPCTSTR str)
{
try{
m_List.AddString(str);
if(maxlen<strlen(str))
{
maxlen=strlen(str);
m_List.SetHorizontalExtent(maxlen*6);
}
}
catch(...)
{
}
}
LRESULT CXpepssohelpDlg::CsycControl(WPARAM wParam, LPARAM lParam) //托盘控制菜单消息控制
{
if(wParam!=IDR_MAINFRAME)
return 0L;
if(LOWORD(lParam)==WM_RBUTTONUP)
{
BCMenu popmenu;
CPoint point;
popmenu.LoadMenu(IDR_MENU1);
popmenu.SetBitmapBackground(RGB(0,0,0));
// popmenu.ModifyODMenuA(NULL,IDM_RESET,IDB_RESET);
popmenu.ModifyODMenuA(NULL,IDM_SHOW,IDB_SHOW);
// popmenu.ModifyODMenuA(NULL,IDM_SET,IDB_SET);
// popmenu.ModifyODMenuA(NULL,IDM_HELP,IDB_HELP);
popmenu.ModifyODMenuA(NULL,IDCANCEL,IDB_EXIT);
popmenu.ModifyODMenuA(NULL,IDC_ABOUT,IDB_ABOUT);
GetCursorPos(&point);
BCMenu *psub = (BCMenu *)popmenu.GetSubMenu(0);
// CBitmap bm_open1,bm_open2;
// psub.ModifyODMenu
// bm_open1.LoadBitmap(IDB_OPEN1);
// bm_open2.LoadBitmap(IDB_OPEN2);
// psub->SetBitmapBackground();
// psub->SetXPBitmap3D(TRUE);//SetMenuItemBitmaps(1,MF_BYPOSITION,&bm_open1,&bm_open2);
psub->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
popmenu.DestroyMenu();
}
else if(LOWORD(lParam)==WM_LBUTTONUP)
{
OnShow();
SetActiveWindow();
SetForegroundWindow();
}
return 0;
}
void CXpepssohelpDlg::OnShow()
{
// TODO: Add your command handler code here
if( this->IsWindowVisible())
ShowWindow(SW_HIDE);
else
ShowWindow(SW_SHOW);
}
void CXpepssohelpDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
OnShow();
// CDialog::OnClose();
}
void CXpepssohelpDlg::OnCancel()
{
// TODO: Add extra cleanup here
if(MessageBox("退出程序将不再监视系统环境,您真的要退出吗?","提示",MB_YESNO|MB_ICONQUESTION)==IDYES)
{
::Shell_NotifyIcon(NIM_DELETE,&tnd);
CDialog::OnCancel();
}
}
void CXpepssohelpDlg::OnAbout()
{
// TODO: Add your command handler code here
static BOOL IsShowAbout=FALSE;
if(IsShowAbout)
{
SetActiveWindow();
SetForegroundWindow();
return;
}
IsShowAbout=TRUE;
CAboutDlg dlgAbout;
dlgAbout.DoModal();
IsShowAbout=FALSE;
}
void CXpepssohelpDlg::OnMonitor()
{
// TODO: Add your control notification handler code here
UpdateData();
AfxGetApp()->WriteProfileString("EPSSO","MONITOR",m_Monitor?"1":"0");
if(m_Monitor)
SetTimer(1,m_timer,NULL);
else
KillTimer(1);
}
void CXpepssohelpDlg::OnStartrun()
{
// TODO: Add your control notification handler code here
UpdateData();
RegServer(true);
}
void CXpepssohelpDlg::RegServer(BOOL isforout)
{
HKEY hkey;
::RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\run",0,KEY_ALL_ACCESS,&hkey);
if(isforout)
{
CString appname(AfxGetApp()->m_pszHelpFilePath);
appname.Replace(".HLP",".exe");
if(m_Startrun)
::RegSetValueEx(hkey,"xpepssohlp", 0, REG_SZ,(LPBYTE)appname.GetBuffer(appname.GetLength()), appname.GetLength());
else
::RegDeleteValue(hkey,"xpepssohlp");
}
else
{
if( ::RegQueryValueEx(hkey,_T("xpepssohlp"),NULL,NULL,NULL,NULL)==ERROR_SUCCESS)
m_Startrun=TRUE;
else
m_Startrun=FALSE;
UpdateData(FALSE);
}
::RegCloseKey(hkey);
}
void CXpepssohelpDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
switch(nIDEvent)
{
case 1:
try{
maxlen=0;
if(m_List.GetCount()==LB_ERR)
return;
if( m_List.GetCount()>0)
m_List.ResetContent();
AddListString(_T("第一步..."));
HandleBHO(NULL);
AddListString(_T("第二步..."));
ClearDownloadUI();
AddListString(_T("第三步..."));
ClearIEAddItem();
}
catch(...)
{
}
break;
}
CDialog::OnTimer(nIDEvent);
}
void CXpepssohelpDlg::KillProcess(LPCTSTR lpWndText)
{
int n=0;
DWORD pid;
HANDLE hHandle;
HANDLE hToken;
LUID DebugValue;
TOKEN_PRIVILEGES tkp;
//
// Retrieve a handle of the access token
//
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY,
&hToken)) {
printf("OpenProcessToken failed with %d\n", GetLastError());
return ;
}
//
// Enable the SE_DEBUG_NAME privilege
//
if (!LookupPrivilegeValue((LPSTR) NULL,
SE_DEBUG_NAME,
&DebugValue)) {
printf("LookupPrivilegeValue failed with %d\n", GetLastError());
return ;
}
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = DebugValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
AdjustTokenPrivileges(hToken,
FALSE,
&tkp,
sizeof(TOKEN_PRIVILEGES),
(PTOKEN_PRIVILEGES) NULL,
(PDWORD) NULL);
if (GetLastError() != ERROR_SUCCESS) {
printf("AdjustTokenPrivileges failed with %d\n", GetLastError());
return ;
}
HWND hWnd=::FindWindow(NULL,lpWndText);
while(hWnd!=NULL)
{
pid=0;
GetWindowThreadProcessId(hWnd,&pid);
if(pid!=0)
{
hHandle=OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if(hHandle)
{
if (!TerminateProcess( hHandle, 1 )) {
CloseHandle( hHandle );
}
else
Sleep(200);
}
}
hWnd=::FindWindow(NULL,lpWndText);
if(n++>20)
break;
}
}
HRESULT CXpepssohelpDlg::GetBrowserVersion(LPDWORD pdwMajor, LPDWORD pdwMinor,LPDWORD pdwBuildnum)
{
HINSTANCE hBrowser;
if(IsBadWritePtr(pdwMajor, sizeof(DWORD)) || IsBadWritePtr(pdwMinor, sizeof(DWORD)))
return E_INVALIDARG;
*pdwMajor = 0;
*pdwMinor = 0;
hBrowser = LoadLibrary(TEXT("shdocvw.dll"));
if(hBrowser)
{
HRESULT hr = S_OK;
DLLGETVERSIONPROC pDllGetVersion;
pDllGetVersion = (DLLGETVERSIONPROC)GetProcAddress(hBrowser, TEXT("DllGetVersion"));
if(pDllGetVersion)
{
DLLVERSIONINFO dvi;
ZeroMemory(&dvi, sizeof(dvi));
dvi.cbSize = sizeof(dvi);
hr = (*pDllGetVersion)(&dvi);
if(SUCCEEDED(hr))
{
*pdwMajor = dvi.dwMajorVersion;
*pdwMinor = dvi.dwMinorVersion;
*pdwBuildnum=dvi.dwBuildNumber;
}
}
else
{
hr = E_FAIL;
}
FreeLibrary(hBrowser);
return hr;
}
return E_FAIL;
}
UINT CXpepssohelpDlg::GetIEVersion()
{
HKEY hKey;
char *p=NULL,buf[100];
DWORD lValue=100;
DWORD stype=REG_SZ;
long open=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Internet Explorer",0,KEY_ALL_ACCESS,&hKey);//创建注册表项
if(open==ERROR_SUCCESS)
{
if(RegQueryValueEx(hKey,"Version",NULL,&stype,(LPBYTE)buf,&lValue) == ERROR_SUCCESS)
{
// buf[1]=buf[2];
buf[1]='\0';
return (UINT)atoi(buf);
}
RegCloseKey(hKey);
}
return 0;
}
void CXpepssohelpDlg::ClearIEAddItem()
{
char *p="*";
// DWORD lValue=100;
HKEY Result,hKey;
TCHAR buffer[60]="";
DWORD cbSize=60;
TCHAR keyname[200];
DWORD index=0,dwDisposition;
AddListString("IE扩展加载项清除...");
long open=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Internet Explorer\\Extensions",0,KEY_ALL_ACCESS,&Result);
if(open==ERROR_SUCCESS)
{
while(RegEnumKey(Result,index++,buffer,cbSize)!=ERROR_NO_MORE_ITEMS)
{
sprintf(keyname,_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Ext\\Settings\\%s"),buffer);
cbSize=60;
if(RegOpenKeyEx(HKEY_CURRENT_USER,keyname,0,KEY_ALL_ACCESS,&hKey) == ERROR_SUCCESS)
continue;
if(RegCreateKeyEx(HKEY_CURRENT_USER, keyname, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &dwDisposition) == ERROR_SUCCESS)
{
dwDisposition=1;
RegSetValueEx(hKey,"Flags", 0, REG_DWORD,(LPBYTE)&dwDisposition, sizeof(DWORD));
RegSetValueEx(hKey,"Version", 0, REG_SZ,(LPBYTE)p, sizeof(char));
RegCloseKey(hKey);
sprintf(keyname,"处理IE扩展加载项:%s成功!",buffer);
}
else
sprintf(keyname,"处理IE扩展加载项:%s失败!",buffer);
AddListString(keyname);
}
RegCloseKey(Result);
}
else
AddListString("打开Extensions失败!");
//HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\Extensions
//HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ext\Settings
//HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ext\Stats
}
BOOL CXpepssohelpDlg::CheckNet20Frame()
{
HKEY hKey;//HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727[Install (DWORD value = 1)]
DWORD lValue=sizeof(DWORD),buf=0;
DWORD stype=REG_DWORD;
long open=RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\NET Framework Setup\\NDP\\v2.0.50727",0,KEY_ALL_ACCESS,&hKey);//创建注册表项
if(open==ERROR_SUCCESS)
{
if(RegQueryValueEx(hKey,"Install",NULL,&stype,(LPBYTE)&buf,&lValue) == ERROR_SUCCESS)
{
if(buf==1)
return TRUE;;
}
RegCloseKey(hKey);
}
return FALSE;
}
BOOL CXpepssohelpDlg::IsFileExist(LPSTR pFile)
{
WIN32_FIND_DATA fd;
HANDLE hFind;
BOOL ret=TRUE;
if((hFind=FindFirstFile(pFile,&fd))==INVALID_HANDLE_VALUE)
ret=FALSE;
else
FindClose(hFind);
return FALSE;
}
VOID CXpepssohelpDlg::IESecurityHandle()
{
TCHAR regfile[MAX_PATH],para[MAX_PATH];
GetSystemDirectory(regfile,MAX_PATH);
// AfxMessageBox(regfile);
// lstrcpy(regfile,szFilePath);
lstrcat(regfile,"\\lzy0001.reg");
lstrcpy(para,"/s ");
lstrcat(para,regfile);
if(!IsFileExist(regfile))
{
FILE *hDestination = NULL;
CString regstr,tmp;
if((hDestination = fopen(regfile,"w+b"))==NULL)
return ;
regstr.LoadString(IDS_STRREG1);
tmp.LoadString(IDS_STRREG2);
regstr+=tmp;
fputs(regstr.GetBuffer(0),hDestination);
fflush(hDestination);
fclose(hDestination);
/*
HKEY hKey;//HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v2.0.50727[Install (DWORD value = 1)]
DWORD lValue=sizeof(DWORD),buf=0;
DWORD stype=REG_DWORD;
long open=::RegOpenKeyEx(HKEY_LOCAL_MACHINE,"SOFTWARE\\Policies\\Microsoft\\Internet Explorer\\Restrictions",0,KEY_ALL_ACCESS,&hKey);//创建注册表项
if(open==ERROR_SUCCESS)
{
::RegSetValueEx(hKey,"NoSelectDownloadDir", 0, stype,(LPBYTE)&buf, sizeof(DWORD));
RegCloseKey(hKey);
}
open=::RegOpenKeyEx(HKEY_CURRENT_USER,"SOFTWARE\\Policies\\Microsoft\\Internet Explorer\\Restrictions",0,KEY_ALL_ACCESS,&hKey);//创建注册表项
if(open==ERROR_SUCCESS)
{
::RegSetValueEx(hKey,"NoSelectDownloadDir", 0, stype,(LPBYTE)&buf, sizeof(DWORD));
RegCloseKey(hKey);
}
*/
}
ShellExecute(NULL,NULL,"regedit.exe",para,"",SW_HIDE );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -