#include "StdAfx.h"
#include "GlobalDealMsg.h"
#include "Interface.h"
#include "Http_Data_Api_Php.h"
#include "Http_Data_Api_Server.h"
#include <KHAboutString.h>
#include <map>
#include <Shobjidl.h>
#include <atlstr.h>
#include <Shlobj.h>
#include <process.h>
#include <Psapi.h>
#pragma comment(lib ,"Psapi.lib")
#include <mwf/KHAboutProcess.h>
#include "dlg_tips.h"
#include "libwz_web.h"
std::map<int,int> g_MapMonthLastDay;
extern HWND g_hMain;
void StartOneProcess(std_string & strVoicePath)
{
STARTUPINFOA si = { sizeof(STARTUPINFOA) };
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
int bRet = CreateProcessA(NULL, LPSTR(strVoicePath.c_str()), NULL, NULL, FALSE, NULL, NULL, NULL, &si, &pi);
if (bRet == 0)
{
//进程启动失败
return;
}
}
void KillProcess(TCHAR target[]) //参数为进程名
{
DWORD aps[1024], cbNeeded, cbNeeded2, i;
TCHAR buffer[256];
BOOL killed;
HANDLE hProcess;
HMODULE hModule;
killed = FALSE;
EnumProcesses(aps, sizeof(aps), &cbNeeded);
for(i = 0; i < cbNeeded/sizeof(DWORD); ++i)
{
if(!(hProcess = OpenProcess(PROCESS_TERMINATE |
PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,FALSE, aps[i])))
continue;
if(!EnumProcessModules(hProcess, &hModule,
sizeof(hModule), &cbNeeded2))
continue;
GetModuleBaseName(hProcess, hModule, buffer, 256);
if(lstrcmpi(buffer, target) == 0)
{
if(TerminateProcess(hProcess, 0))
killed = TRUE;
CloseHandle(hProcess);
break;
}
CloseHandle(hProcess);
}
}
void ClearWebCache()
{
TCHAR szPath[MAX_PATH];
//清internet临时文件
DeleteUrlCache(File);
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_INTERNET_CACHE, FALSE))
{ //得到临时目录,并清空它.
EmptyDirectory(szPath);
}
//Cookie的清除
DeleteUrlCache(Cookie);
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_COOKIES, FALSE))
{//得到目录,并清空
EmptyDirectory(szPath);
}
//清收藏夹中的内容
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_FAVORITES, FALSE))
{ //得到目录,并清空
EmptyDirectory(szPath);
}
//清除网络联接历史记录
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_NETHOOD, FALSE))
{ //得到目录,并清空
EmptyDirectory(szPath);
}
// //清"文档"中的历史记录
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_RECENT, FALSE))
{
EmptyDirectory(szPath);
}
// //清系统临时文件夹
if (GetTempPath(MAX_PATH, szPath))//得到系统临时目录
{
EmptyDirectory(szPath, TRUE);
}
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RecentDocs"));
//浏览器地址栏历史地址的清除
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\TypedURLs"));
// 清除自动密码历史记录
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\IntelliForms"));
// 清RAS自动拨号历史记录
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\RAS Autodial\\Addresses"));
// 清空回收站
SHEmptyRecycleBin(NULL, NULL,
SHERB_NOCONFIRMATION | SHERB_NOPROGRESSUI | SHERB_NOSOUND);
// 清除"运行"中的自动匹配历史记录
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\RunMRU"));
// 清除上次登陆用户记录
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"),
_T("DefaultUserName"));
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"),
_T("AltDefaultUserName"));
SHDeleteValue(HKEY_LOCAL_MACHINE,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Winlogon"),
_T("DefaultUserName"));
//清除"查找文件"自动匹配历史记录
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Doc Find Spec MRU"));
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\Explorer Bars\\{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}\\ContainingTextMRU"));
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\Explorer Bars\\{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}\\FilesNamedMRU"));
// 清除"查找计算机"自动匹配历史记录
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FindComputerMRU"));
SHDeleteKey(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Internet Explorer\\Explorer Bars\\{C4EE31F3-4768-11D2-BE5C-00A0C9A83DA1}\\ComputerNameMRU"));
// 清远程登录历史记录
CString sKey;
for (int i=1; i<=8; i++)
{
sKey.Format(_T("Machine%d"), i);
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Telnet"), sKey);
sKey.Format(_T("Service%d"), i);
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Telnet"), sKey);
sKey.Format(_T("TermType%d"), i);
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Telnet"), sKey);
}
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Telnet"), _T("LastMachine"));
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Telnet"), _T("LastService"));
SHDeleteValue(HKEY_CURRENT_USER,
_T("Software\\Microsoft\\Telnet"), _T("LastTermType"));
/
// 清除表单自动完成历史记录
CString sKeyTwo;
DWORD dwRet;
if (IsWindows2k() || IsWindowsNT())//先判断系统
{
CString sBaseKey;
SECURITY_DESCRIPTOR NewSD;
BYTE* pOldSD;
PACL pDacl = NULL;
PSID pSid = NULL;
TCHAR szSid[256];
if (GetUserSid(&pSid))
{
//get the hiden key name
GetSidString(pSid, szSid);
sKeyTwo = _T("Software\\Microsoft\\Protected Storage System Provider\\");
sKeyTwo += szSid;
//get old SD
sBaseKey = sKeyTwo;
GetOldSD(HKEY_CURRENT_USER, sBaseKey, &pOldSD);
//set new SD and then clear
if (CreateNewSD(pSid, &NewSD, &pDacl))
{
RegSetPrivilege(HKEY_CURRENT_USER, sKeyTwo, &NewSD, FALSE);
sKeyTwo += _T("\\Data");
RegSetPrivilege(HKEY_CURRENT_USER, sKeyTwo, &NewSD, FALSE);
sKeyTwo += _T("\\e161255a-37c3-11d2-bcaa-00c04fd929db");
RegSetPrivilege(HKEY_CURRENT_USER, sKeyTwo, &NewSD, TRUE);
dwRet = SHDeleteKey(HKEY_CURRENT_USER, sKeyTwo);
}
if (pDacl != NULL)
HeapFree(GetProcessHeap(), 0, pDacl);
//restore old SD
if (pOldSD)
{
RegSetPrivilege(HKEY_CURRENT_USER, sBaseKey,
(SECURITY_DESCRIPTOR*)pOldSD, FALSE);
delete pOldSD;
}
}
if (pSid)
HeapFree(GetProcessHeap(), 0, pSid);
}
//win9x
DWORD dwSize = MAX_PATH;
TCHAR szUserName[MAX_PATH];
GetUserName(szUserName, &dwSize);
sKeyTwo = _T("Software\\Microsoft\\Protected Storage System Provider\\");
sKeyTwo += szUserName;
sKeyTwo += _T("\\Data\\e161255a-37c3-11d2-bcaa-00c04fd929db");
dwRet = SHDeleteKey(HKEY_LOCAL_MACHINE, sKeyTwo);
// 清浏览网址历史记录
HRESULT hr;
IUrlHistoryStg2* pUrlHistoryStg2 = NULL;
hr = CoCreateInstance(CLSID_CUrlHistory, NULL,
CLSCTX_INPROC_SERVER, IID_IUrlHistoryStg2,
(void**)&pUrlHistoryStg2);
if (SUCCEEDED(hr))
{
hr = pUrlHistoryStg2->ClearHistory();
pUrlHistoryStg2->Release();
}
// 如果上面代码不能清
// 则有下面的,不完美,但能工作.
GetWindowsDirectory(szPath, MAX_PATH);
_tcscat(szPath, _T("\\History"));
EmptyDirectory(szPath, FALSE, TRUE);
if (SHGetSpecialFolderPath(NULL, szPath, CSIDL_HISTORY, FALSE))
{
EmptyDirectory(szPath, FALSE, TRUE);
}
///
}