问题描述
我正在使用嵌入式 Visual C++ 4 为 Windows CE 6.0 开发应用程序.
I am developing an application for Windows CE 6.0 in embedded Visual C++ 4.
我使用以下简单代码创建了一个简单的控制台应用程序(WCE 应用程序),平台为Pocket PC 2003":
I created a simple console application (WCE Application) with platform "Pocket PC 2003" with the following simple code:
#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".
This simple code works correctly on my WinCE 6.0 device and "alphabet.txt" is created.
但是当我创建一个基于对话框的项目(WCE MFC AppWizard(exe))并在我的对话框窗口初始化之前将此代码放在我的项目的主类中时它不起作用并且没有创建alphabet.txt"文件没有任何消息,我的应用程序无法打开.
But when I create a dialog based project (WCE MFC AppWizard(exe)) and put this code in main class of my project before the initialization of my dialog window it does not work and no "alphabet.txt" file is created and my app does not open without any messages.
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;
}
为什么它不起作用,我该如何解决这个问题?
Why it does not work and how can I resolve this problem?
提前致谢,
推荐答案
目标设备上是否有 MFC 运行时?它们还必须是您的应用程序所针对的对象.请注意,eVC 4.0 使用了 mfcce400.dll,它根本没有随 Platform Builder 6.0 一起提供(实际上 IIRC MFC 甚至不在 CE 6.0 操作系统目录中,Studio '08 为设备使用了更新的 MFC 版本).您必须将 mfcce400 二进制文件(它们在 eVC SDK 中)与您的应用程序一起分发.
Does the target device have the MFC runtimes on it? They also have to be the ones your app is built for. Be aware that eVC 4.0 used mfcce400.dll, which did not ship with Platform Builder 6.0 at all (in fact IIRC MFC isn't even in the CE 6.0 OS catalog and Studio '08 used a newer MFC version for devices). You'll have to distribute the mfcce400 binaries (they're in the eVC SDKs) along with your app.
这篇关于为什么简单的控制台应用程序运行,但基于对话框的不在 WIN CE 6.0 中运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!