1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #include "FourthPage.h"
21 #include "ConfigPropertySheet.h"
22 #include "SharedSecret.h"
24 #include <WinServices.h>
26 #define MAX_KEY_LENGTH 255
29 IMPLEMENT_DYNCREATE(CFourthPage
, CPropertyPage
)
32 //---------------------------------------------------------------------------------------------------------------------------
33 // CFourthPage::CFourthPage
34 //---------------------------------------------------------------------------------------------------------------------------
36 CFourthPage::CFourthPage()
38 CPropertyPage(CFourthPage::IDD
)
40 //{{AFX_DATA_INIT(CFourthPage)
45 //---------------------------------------------------------------------------------------------------------------------------
46 // CFourthPage::~CFourthPage
47 //---------------------------------------------------------------------------------------------------------------------------
49 CFourthPage::~CFourthPage()
54 //---------------------------------------------------------------------------------------------------------------------------
55 // CFourthPage::DoDataExchange
56 //---------------------------------------------------------------------------------------------------------------------------
58 void CFourthPage::DoDataExchange(CDataExchange
* pDX
)
60 CPropertyPage::DoDataExchange(pDX
);
61 //{{AFX_DATA_MAP(CFourthPage)
63 DDX_Control(pDX
, IDC_POWER_MANAGEMENT
, m_checkBox
);
66 BEGIN_MESSAGE_MAP(CFourthPage
, CPropertyPage
)
67 //{{AFX_MSG_MAP(CFourthPage)
70 ON_BN_CLICKED(IDC_POWER_MANAGEMENT
, &CFourthPage::OnBnClickedPowerManagement
)
75 //---------------------------------------------------------------------------------------------------------------------------
76 // CFourthPage::SetModified
77 //---------------------------------------------------------------------------------------------------------------------------
79 void CFourthPage::SetModified( BOOL bChanged
)
81 m_modified
= bChanged
;
83 CPropertyPage::SetModified( bChanged
);
87 //---------------------------------------------------------------------------------------------------------------------------
88 // CFourthPage::OnSetActive
89 //---------------------------------------------------------------------------------------------------------------------------
92 CFourthPage::OnSetActive()
94 CConfigPropertySheet
* psheet
;
99 BOOL b
= CPropertyPage::OnSetActive();
101 psheet
= reinterpret_cast<CConfigPropertySheet
*>(GetParent());
102 require_quiet( psheet
, exit
);
104 m_checkBox
.SetCheck( 0 );
106 // Now populate the browse domain box
108 err
= RegCreateKeyEx( HKEY_LOCAL_MACHINE
, kServiceParametersNode L
"\\Power Management", 0,
109 NULL
, REG_OPTION_NON_VOLATILE
, KEY_READ
|KEY_WRITE
, NULL
, &key
, NULL
);
110 require_noerr( err
, exit
);
112 dwSize
= sizeof( DWORD
);
113 err
= RegQueryValueEx( key
, L
"Enabled", NULL
, NULL
, (LPBYTE
) &enabled
, &dwSize
);
114 require_noerr( err
, exit
);
116 m_checkBox
.SetCheck( enabled
);
129 //---------------------------------------------------------------------------------------------------------------------------
131 //---------------------------------------------------------------------------------------------------------------------------
144 //---------------------------------------------------------------------------------------------------------------------------
145 // CFourthPage::Commit
146 //---------------------------------------------------------------------------------------------------------------------------
149 CFourthPage::Commit()
155 err
= RegCreateKeyEx( HKEY_LOCAL_MACHINE
, kServiceParametersNode L
"\\Power Management", 0,
156 NULL
, REG_OPTION_NON_VOLATILE
, KEY_READ
|KEY_WRITE
, NULL
, &key
, NULL
);
157 require_noerr( err
, exit
);
159 enabled
= m_checkBox
.GetCheck();
160 err
= RegSetValueEx( key
, L
"Enabled", NULL
, REG_DWORD
, (LPBYTE
) &enabled
, sizeof( enabled
) );
161 require_noerr( err
, exit
);
172 //---------------------------------------------------------------------------------------------------------------------------
173 // CFourthPage::OnBnClickedRemoveBrowseDomain
174 //---------------------------------------------------------------------------------------------------------------------------
178 void CFourthPage::OnBnClickedPowerManagement()
186 sprintf( buf
, "check box: %d", m_checkBox
.GetCheck() );
188 OutputDebugStringA( buf
);
190 // TODO: Add your control notification handler code here