我正在为嵌入式 Visual C++ 4 中的 Windows CE 6.0 开发应用程序。
我使用以下简单代码创建了一个带有平台“Pocket PC 2003”的简单控制台应用程序(WCE 应用程序):
#include "stdafx.h"
#include <stdio.h>
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
FILE * pFile;
char c;
pFile=fopen("alphabet.txt","wt");
for (c = 'A' ; c <= 'Z' ; c++) {
putc (c , pFile);
}
fclose (pFile);
return 0;
}
这个简单的代码在我的 WinCE 6.0 设备上正常工作,并创建了“alphabet.txt”。
但是当我创建一个基于对话框的项目(WCE MFC AppWizard(exe))并在我的对话框窗口初始化之前将此代码放在我的项目的主类中时它不起作用并且没有创建“alphabet.txt”文件和我的应用程序没有任何消息就无法打开。
BOOL CFffffApp::InitInstance()
{
// 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.
FILE * pFile;
char c;
pFile=fopen("alphabet.txt","wt");
for (c = 'A' ; c <= 'Z' ; c++) {
putc (c , pFile);
}
fclose (pFile);
CFffffDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
为什么它不起作用,我该如何解决这个问题?
提前致谢,