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 pathCleanRun.cpp
92 lines (80 loc) · 2.12 KB
/
CleanRun.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
// leanRun.cpp : implementation file
//
#include "stdafx.h"
#include "resource.h"
#include "CleanRun.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CleanRun dialog
CleanRun::CleanRun(CWnd* pParent /*=NULL*/)
: CDialog(CleanRun::IDD, pParent)
{
//{{AFX_DATA_INIT(CleanRun)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CleanRun::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CleanRun)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CleanRun, CDialog)
//{{AFX_MSG_MAP(CleanRun)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CleanRun message handlers
BOOL CleanRun::OnInitDialog()
{
HKEY hkey;
long rep;
CDialog::OnInitDialog();
rep=RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("EXPLORER\\RunHistory"),0,
KEY_ALL_ACCESS,&hkey);
RegCloseKey(hkey);
if(rep==ERROR_SUCCESS){
this->CheckDlgButton(IDC_NoRun,false);
}
else{
this->CheckDlgButton(IDC_NoRun,true);
}
return TRUE;
}
void CleanRun::OnOK()
{
HKEY hkey;
DWORD dwDisposition;
DWORD val=0;
LONG cond;
int reponse;
CString c;
reponse=this->IsDlgButtonChecked(IDC_NoRun);
if(reponse==BST_CHECKED){
RegDeleteKey(HKEY_LOCAL_MACHINE,TEXT("EXPLORER\\RunHistory"));
}else{
RegCreateKeyExW(HKEY_LOCAL_MACHINE ,TEXT("EXPLORER\\RunHistory"), \
0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition);
RegCloseKey(hkey);
reponse=this->IsDlgButtonChecked(IDC_CleanRun);
if(reponse==BST_CHECKED){
do{
c.Format(_T("%d"),val);
RegOpenKeyEx(HKEY_LOCAL_MACHINE,TEXT("EXPLORER\\RunHistory"),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();
}