David,
Thank you for replying
I am a VB programmer & have been since version 3 but I want to make the
application unmanaged so not reliant on any .NET Framework. In VB.NET, I
have written the code but have no idea in C++. Using Visual Studio 2008
Professional I want to create a Win32 C++ application. Here is some of my
VB.NET code:
Imports Microsoft.Win32
Private Function GetStartupValue() As Integer
Dim intTemp As Integer = 0
Try
reg = Registry.LocalMachine.OpenSubKey(strKey, False)
If Not (reg Is Nothing) Then
intTemp = reg.GetValue(strValue)
reg.Close()
End If
Return intTemp
Catch ex As Exception
MessageBox.Show("Unable to read registry setting", Me.Text)
End Try
End Function
Private Sub frmDisable_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If GetStartupValue() = 1 Then
chkDisable.Checked = False
Else
chkDisable.Checked = True
End If
End Sub
Private Sub chkDisable_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles chkDisable.CheckedChanged
Try
reg = Registry.LocalMachine.OpenSubKey(strKey, True)
If chkDisable.Checked = True Then
reg.SetValue(strValue, 0)
Else
reg.SetValue(strValue, 1)
End If
If Not (reg Is Nothing) Then reg.Close()
Catch ex As Exception
MessageBox.Show("Unable to change reg setting", Me.Text)
End Try
End Sub
The value I am getting is a DWORD which is either 0 or 1
----------------------
I created a simple MFC EXE application, added a checkbox, right-clicked it &
added a variable IsDisabled then used that variable to handle the checkbox
click:
void CUACDlg::OnBnClickedchkdisable()
{
HKEY hkey;
DWORD dwDisposition;
DWORD data;
BOOL IsDisabled=false;
int size = sizeof (DWORD);
if(IsDisabled)
{
IsDisabled=1;
RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Some\\Key\\Here"), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwDisposition);
RegSetValueEx(hkey, TEXT("Disabled"), 0, REG_DWORD, (LPBYTE)&data, size);
//RegCloseKey(hkey);
}
else{
IsDisabled=0;
RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Some\\Key\\Here"), 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hkey, &dwDisposition);
RegSetValueEx(hkey, TEXT("Disabled"), 0, REG_DWORD, (LPBYTE)&data, size);
//RegCloseKey(hkey);
}
RegCloseKey(hkey);
}
Scribble Tutorial:
http://msdn.microsoft.com/en-us/library/aa716527(VS.60).aspx
Any ideas?