void CMainFrame::OnImportRegedit()
{
// TODO: Add your command handler code here
CFileDialog dlg(TRUE,NULL,NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Register File(*.reg)|*.reg||");
if(dlg.DoModal() == IDOK)
{
CString strFile = dlg.GetPathName();
CString strParameters;
strParameters = "/s /"" + strFile + "/"";
ShellExecute(NULL,"open","regedit.exe",
strParameters,NULL,SW_HIDE);
//andy-20100607 for import regedit
//注册表不能立马生效,下面读取不到最新的值
::SendMessage(HWND_BROADCAST,WM_SETTINGCHANGE,NULL,NULL); //使得注册表更新立马生效
... //读取注册表的值
}
}
void CMainFrame::OnExportRegedit()
{
// TODO: Add your command handler code here
CString strKey;
strKey.LoadString(IDS_SUBKEY_YSENGRAVING);
CFileDialog dlg(FALSE,"reg",NULL,OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
"Register File(*.reg)|*.reg||");
if(dlg.DoModal() == IDOK)
{
CString strFile = dlg.GetPathName();
CString strParameters;
strParameters = "/e /"" + strFile + "/" /"" + "HKEY_CURRENT_USER//" + strKey + "/"";
ShellExecute(NULL,"open","regedit.exe",
strParameters, NULL , SW_SHOWNORMAL);
}
}