Registry query and modification program

Source: Internet
Author: User
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 );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.