Cstring m_strowner, m_strcompany;
Void cregdlg: onbnclickedquery ()
{
// Todo: add the control notification handler code here
Updatedata (true );
Hkey;
Lpctstr data_set = _ T ("SOFTWARE \ Microsoft \ Windows \ CurrentVersion \\");
Long ret0 = (: regopenkeyex (HKEY_LOCAL_MACHINE, data_set, 0, key_read, & hkey ));
If (ret0! = Error_success)
{
Afxmessagebox (_ T ("error "));
Return;
}
Lpbyte company_get = new byte [160];
DWORD type_2 = REG_SZ;
DWORD cbdata_2 = 160;
Long ret2 =: regqueryvalueex (hkey, _ T ("registeredorganization"), null, & type_2, company_get, & cbdata_2 );
If (ret2! = Error_success)
{
Afxmessagebox (_ T ("error1 "));
Return;
}
Int I = 0;
For (I = 0; I <m_strcompany.getlength () + 1; I ++)
// While (cstring (company_get + 2 * I )! = "")
{
M_strcompany + = cstring (company_get + 2 * I );
// I ++;
}
// Afxmessagebox (m_strcompany );
// M_strcompany = cstring (company_get );
Getdlgitem (idc_edit1)-> setwindowtext (m_strcompany );
M_strcompany = "";
Delete [] company_get;
: Regclosekey (hkey );
Updatedata (false );
}
Void cregdlg: onbnclickedchange ()
{
// Todo: add the control notification handler code here
Updatedata (true );
Hkey;
Lpctstr data_set = _ T ("SOFTWARE \ Microsoft \ Windows \ CurrentVersion \\");
Long ret0 = (: regopenkeyex (HKEY_LOCAL_MACHINE, data_set, 0, key_write, & hkey ));
If (ret0! = Error_success)
{
Afxmessagebox (_ T ("error "));
Return;
}
Getdlgitem (idc_edit2)-> getwindowtext (m_strcompany );
Lpbyte company_set = (lpbyte) m_strcompany.getbuffer (m_strcompany.getlength () + 1 );
DWORD type_2 = REG_SZ;
DWORD cbdata_2 = 2 * m_strcompany.getlength () + 1;
Long ret2 =: regsetvalueex (hkey, _ T ("registeredorganization"), null, type_2, company_set, cbdata_2 );
If (ret2! = Error_success)
{
Afxmessagebox (_ T ("error1 "));
Return;
}
Else
{
Afxmessagebox (_ T ("Registry Modification completed "));
}
M_strcompany = "";
: Regclosekey (hkey );
Updatedata (false );
}