为什么调用RegQueryValueEx()后再调用CFileDialog::GetPathName()会提示出错?
BOOL CSimplePlayerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
isFullScreen = FALSE;
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
mVideoWindow.ModifyStyle(0, WS_CLIPCHILDREN);
mSliderGraph.SetRange(0, 1000);
mSliderGraph.SetPos(0);
memset(path, 0, MAX_PATH);
char regname[]="Software\\MDInstallInfo";
HKEY hkResult;
DWORD dwSize;
DWORD type_1=REG_SZ;
int ret=RegOpenKeyEx(HKEY_CURRENT_USER,regname,0, KEY_READ, &hkResult);
ret=RegQueryValueEx(hkResult,"path",0,&type_1,(LPBYTE)path,&dwSize);
RegCloseKey(hkResult);
return TRUE; // return TRUE unless you set the focus to a control
}
void CSimplePlayerDlg::OnButtonOpen()
{
// TODO: Add your control notification handler code here
CString strFilter = "AVI File (*.avi)|*.avi|";
CFileDialog dlgOpen(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_HIDEREADONLY,
strFilter, this);
if (IDOK == dlgOpen.DoModal())
{
mSourceFile = dlgOpen.GetPathName();
// Rebuild the file playback filter graph
CreateGraph();
OnButtonPlay();
}
}
如果在Init中去掉ret=RegQueryValueEx(hkResult,"path",0,&type_1,(LPBYTE)path,&dwSize);就能正常播放文件,加上后执行就出错,程序退出