This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCleanAddress.cpp
92 lines (80 loc) · 2.19 KB
/
CleanAddress.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// leanAddress.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CleanAddress.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CleanAddress dialog
CleanAddress::CleanAddress(CWnd* pParent /*=NULL*/)
: CDialog(CleanAddress::IDD, pParent)
{
//{{AFX_DATA_INIT(CleanAddress)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CleanAddress::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CleanAddress)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CleanAddress, CDialog)
//{{AFX_MSG_MAP(CleanAddress)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CleanAddress message handlers
void CleanAddress::OnOK()
{
HKEY hkey;
DWORD dwDisposition;
DWORD val=0;
LONG cond;
int reponse;
CString c;
reponse=this->IsDlgButtonChecked(IDC_NoAdd);
if(reponse==BST_CHECKED){
RegDeleteKey(HKEY_LOCAL_MACHINE,TEXT("EXPLORER\\AddressHistory"));
}else{
RegCreateKeyExW(HKEY_LOCAL_MACHINE ,TEXT("EXPLORER\\AddressHistory"), \
0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition);
RegCloseKey(hkey);
reponse=this->IsDlgButtonChecked(IDC_CleanAdd);
if(reponse==BST_CHECKED){
do{
c.Format(_T("%d"),val);
RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("EXPLORER\\AddressHistory"),0,
KEY_SET_VALUE,&hkey);
cond=RegDeleteValue(hkey,c);
RegCloseKey(hkey);
val++;
}while(cond==ERROR_SUCCESS);
AfxMessageBox(_T("Cleaned !"),MB_OK,1);
}else{
AfxMessageBox(_T("Not cleaned !"),MB_OK,2);
}
}
CDialog::OnOK();
}
BOOL CleanAddress::OnInitDialog()
{
HKEY hkey;
long rep;
CDialog::OnInitDialog();
rep=RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("EXPLORER\\AddressHistory"),0,
KEY_ALL_ACCESS,&hkey);
RegCloseKey(hkey);
if(rep==ERROR_SUCCESS){
this->CheckDlgButton(IDC_NoAdd,false);
}
else{
this->CheckDlgButton(IDC_NoAdd,true);
}
return TRUE;
}