程序如下:
BOOL CTestApp::InitInstance()
{
AfxEnableControlContainer();
CoInitialize(NULL);
CDlgLogin login;
if (login.DoModal() != IDOK)
{
return FALSE;
}
#ifdef _AFXDLL
Enable3dControls();// Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
// TODO: You should modify this string to be something appropriate
// such as the name of your company or organization.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(0);  // Load standard INI file options (including MRU)对话框正确运行,但运行到SetRegistryKey出错,跟踪进程序后错误出现在
ASSERT(m_pszRegistryKey == NULL);
m_pszRegistryKey不为空,而且 CDlgLogin login;时就不为空了,这是什么原因造成的,怎样处理!

解决方案 »

  1.   

    把CDlgLogin login;
    if (login.DoModal() != IDOK)
    {
    return FALSE;
    }
    放到Instance函数的LoadStdProfileSettings(0);  // Load standard INI file options (including MRU)后面,return TRUE之前。
    这样应该可以。
      

  2.   

    发现问题是因为我的对话框里有
    CAdoConnection m_sqlcon;
    CAdoRecordSet m_sqlrec;
    两个连接数据库的类成员,如果删除了就可以用了,但我需要连接数据库去验证密码。
    TO QLFTL:你的办法不行,而且也是治标不治本的办法。
      

  3.   

    搞不懂为什么跟CAdoConnection m_sqlcon;
    CAdoRecordSet m_sqlrec;有关?我的对话框类里也有ado和database ,没有你说的问题。
      

  4.   

    SetRegistryKey()
    前再次把m_pszRegistryKey = NULL;看看!
      

  5.   

    我感觉你的对话框都返回IDOK了,所以SetRegistryKey函数好象和对话框对象没有必然关系了,提个建议,你既然在SetRegistryKey中要使用对话框的变量,就将SetRegistryKey函数放到对话框类中处理试试。
      

  6.   

    有人说app中不能使用数据库连接类,有解决办法吗?