c++ - 为什么简单的控制台应用程序可以运行,但基于对话框的应用程序不能在 WIN CE 6.0 中运行?

标签 c++ visual-c++ windows-mobile embedded windows-ce

我正在使用嵌入式 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;
}

为什么它不起作用,我该如何解决这个问题?

提前致谢

最佳答案

目标设备上是否有 MFC 运行时?它们还必须是您的应用程序的构建对象。请注意,eVC 4.0 使用了 mfcce400.dll,它根本没有随 Platform Builder 6.0 一起提供(事实上,IIRC MFC 甚至不在 CE 6.0 操作系统目录中,Studio '08 为设备使用了更新的 MFC 版本)。您必须将 mfcce400 二进制文件(它们在 eVC SDK 中)与您的应用程序一起分发。

关于c++ - 为什么简单的控制台应用程序可以运行,但基于对话框的应用程序不能在 WIN CE 6.0 中运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10959134/

相关文章:

c++ - 我的 Windows CE 60 设备应该使用哪种 CPU 配置?

visual-studio-2010 - VS2010 是否支持 Windows 移动项目?

c++ - C++中 'this'指针的用例

c++ - 高效的数据结构可聚合多列数据

c++ - 难以编写多级 for 循环

c++ - Visual C、WinSock HTTP Req 和非 Windows

c++ - 图像的像素格式始终返回 32 位

c++ - 安全地删除指向指针数组的指针

c++ - 读取应用程序的 list 文件?

c# - 我如何为我的 Windows Mobile 5 应用程序创建数据库并访问它?