InitInstance()中SetRegistryKey的问题

caitou123 2006-01-10 02:10:45
我写的程序,用到了WriteProfileString,用clear后,再重新编译,程序界面没显示出来,看进程表,该程序已经运行,并且cpu占有97%.
我将SetRegistryKey(_T("Local AppWizard-Generated Applications"))改一点为SetRegistryKey(_T("Localx AppWizard-Generated Applications"))//local多个x;
或在注册表里Local AppWizard-Generated Applications下将程序名删除就可以运行了,程序界面是基于 CFormView的.
多多请教,多谢多谢
...全文
521 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜牛 2006-01-21
  • 打赏
  • 举报
回复
没有代码看什么呀?
一个傻冒 2006-01-21
  • 打赏
  • 举报
回复
能不能多提供一点代码啊.
caitou123 2006-01-21
  • 打赏
  • 举报
回复
大家多看看
wotur 2006-01-12
  • 打赏
  • 举报
回复
如果给分我就接点
caitou123 2006-01-12
  • 打赏
  • 举报
回复
现在莫名其妙奇妙又没有问题了,各位有没有遇到过?
schwarzenegger 2006-01-10
  • 打赏
  • 举报
回复
code
taianmonkey 2006-01-10
  • 打赏
  • 举报
回复
This function sets m_pszRegistryKey, which is then used by the GetProfileInt, GetProfileString, WriteProfileInt, and WriteProfileString member functions of CWinApp. If this function has been called, the list of most recently-used (MRU) files is also stored in the registry. The registry key is usually the name of a company. It is stored in a key of the following form: HKEY_CURRENT_USER\Software\<company name>\<application name>\<section name>\<value name>.
caitou123 2006-01-10
  • 打赏
  • 举报
回复
我是把.aps,.ncb,.opt,.clw文件删除后考到家里发现的.还有个问题,我在vc下编译可运行起来,
而在debug目录下的可执行文件就不行,只能改或删除.
caitou123 2006-01-10
  • 打赏
  • 举报
回复
绝对没有循环,而且每次程序运行都要读注册表,改了或删除后就运转正常,如果有循环,应该不可能运行的.
lzzqqq 2006-01-10
  • 打赏
  • 举报
回复
估计是你在读取注册表时有循环,而且没处理好,程序老在循环里打转不能继续向下执行导致主界面显示不出,但进程中已经启动.
再看一下你读取注册表的操作代码是怎么处理的.
动态加载GIF动画 VC 实现 include "stdafx.h" #include "TransparentGif.h" #include "TransparentGifDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CTransparentGifApp BEGIN_MESSAGE_MAP(CTransparentGifApp, CWinAppEx) ON_COMMAND(ID_HELP, &CWinApp::OnHelp) END_MESSAGE_MAP() // CTransparentGifApp 构造 CTransparentGifApp::CTransparentGifApp() { // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance } // 唯一的一个 CTransparentGifApp 对象 CTransparentGifApp theApp; // CTransparentGifApp 初始化 BOOL CTransparentGifApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinAppEx::InitInstance(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); CTransparentGifDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此放置处理何时用 // “确定”来关闭对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用 // “取消”来关闭对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }
C++面向对象编程八皇后问题 BOOL CMyqueenApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #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(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CMyqueenDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CMyqueenView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; VERIFY( 1 == InitSkinMagicLib( AfxGetInstanceHandle(), "Demo" , NULL, NULL ) ); VERIFY( 1 == LoadSkinFromResource( AfxGetInstanceHandle() , "DEFAULT" ,"DEFAULT") ); VERIFY( 1 == SetWindowSkin( m_pMainWnd->m_hWnd , "MainFrame" )); VERIFY( 1 == SetDialogSkin( "Dialog" ) ); //((CMainFrame*)m_pMainWnd)->m_bSkinned = TRUE; //((CMainFrame*)m_pMainWnd)->m_nIndex = 0; m_pMainWnd->SetWindowText("八皇后问题演示"); // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow();
// MyCalculator.cpp : 定义应用程序的类行为。 // #include "stdafx.h" #include "MyCalculator.h" #include "MyCalculatorDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #endif // CMyCalculatorApp BEGIN_MESSAGE_MAP(CMyCalculatorApp, CWinApp) ON_COMMAND(ID_HELP, &CWinApp;::OnHelp) END_MESSAGE_MAP() // CMyCalculatorApp 构造 CMyCalculatorApp::CMyCalculatorApp() { // TODO: 在此处添加构造代码, // 将所有重要的初始化放置在 InitInstance } // 唯一的一个 CMyCalculatorApp 对象 CMyCalculatorApp theApp; // CMyCalculatorApp 初始化 BOOL CMyCalculatorApp::InitInstance() { // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls;); CWinApp::InitInstance(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); CMyCalculatorDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: 在此处放置处理何时用“确定”来关闭 // 对话框的代码 } else if (nResponse == IDCANCEL) { // TODO: 在此放置处理何时用“取消”来关闭 // 对话框的代码 } // 由于对话框已关闭,所以将返回 FALSE 以便退出应用程序, // 而不是启动应用程序的消息泵。 return FALSE; }

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧