清除历史记录.cpp
上传用户:fengliqin8
上传日期:2022-07-28
资源大小:1k
文件大小:2k
- //#include "stdafx.h"
- #include "stdio.h"
- #include "atlbase.h"
- void DelReg_IE();
- void DelMyPointFile(LPSTR name,LPSTR CurrentPath);
- int main()
- {
- char key;
- char WindowRecentPath[]="\Recent";
- char WindowTemp[]="\temp";
- char szWindowsPath[MAX_PATH];
- char szDelPath[MAX_PATH];
- printf("清除IE访问的网址,请输入a.n清除最近访问的文档记录,请输入b.n退出,请按其它.n");
- scanf("%c",&key);
- if(key=='a')
- {
- DelReg_IE();
- printf("清除完毕.n");
- }
- else if(key=='b')
- {
- GetWindowsDirectory(szWindowsPath,MAX_PATH);
- lstrcpy(szDelPath,szWindowsPath);
- lstrcat(szDelPath,WindowRecentPath);
- //删除window最近使用的文件列表
- DelMyPointFile("*.*",szDelPath);
- printf("清除完毕.n");
- }
-
- return 0;
- }
- void DelReg_IE()
- {
- //删除注册表中保存的IE记录
- LPCSTR RootKey="HKEY_CURRENT_USER";
- LPCSTR SubKey="Software\Microsoft\Internet Explorer\TypedURLs";
- RegDeleteKey(HKEY_CURRENT_USER,SubKey);
- }
- void DelMyPointFile(LPSTR name,LPSTR CurrentPath)
- {
- WIN32_FIND_DATA FileData;
- HANDLE hSearch;
- char szHome[MAX_PATH];
- DWORD RightWrong;
- DWORD NameLength;
-
- RightWrong=GetCurrentDirectory(MAX_PATH,szHome);//获取当前目录
- RightWrong=SetCurrentDirectory(CurrentPath);//设置当前目录为需要查找的路径
-
- hSearch = FindFirstFile(name,&FileData);
- if (hSearch!= INVALID_HANDLE_VALUE)
- {
- NameLength=lstrlen(FileData.cFileName);
- DeleteFile(FileData.cFileName);
- while(FindNextFile(hSearch,&FileData))
- {
- NameLength=lstrlen(FileData.cFileName);
- DeleteFile(FileData.cFileName);
- }
- FindClose(hSearch);
- }
- RightWrong=SetCurrentDirectory(szHome);
- }