我用VC自带的串口控件编了一个程序,现在想生成一个.exe文件,可是我生成的文件拿到没安装VC的机器上就不能用了,好像是空间没有包含进.exe文件中,怎么才能把空间也包含进来阿?

解决方案 »

  1.   

    看不懂什么叫空间没包含进.exe应该是MFCxxx.DLL不在系统文件夹中的问题吧。
      

  2.   

    xcopy  MGE.DLL %windir%
    xcopy  mfc42.dll %windir%
    xcopy  msvcrt.dll %windir%
    xcopy  MSCOMM32.OCX %windir%
    regsvr32  %windir%\MSCOMM32.OCX
    1。 运行上面的命令 ,注册控件。
    把上面的东西用文本文件保存,然后改后缀名为 .bat2。 还有就是在程序中注册控件调用 WinAPI  也可、。MSCOMM32.OCX  就这东东沙。
      

  3.   

    在程序的同一个目录运行上面的命令。改后缀名为 .bat 的文件直接运行也可。
      

  4.   

    LoadLibraryEx#include <windows.h>
    #include <stdio.h>#include <lmerr.h>void
    DisplayErrorText(
        DWORD dwLastError
        );#define RTN_OK 0
    #define RTN_USAGE 1
    #define RTN_ERROR 13int
    __cdecl
    main(
        int argc,
        char *argv[]
        )
    {
        if(argc != 2) {
            fprintf(stderr,"Usage: %s <error number>\n", argv[0]);
            return RTN_USAGE;
        }    DisplayErrorText( atoi(argv[1]) );    return RTN_OK;
    }void
    DisplayErrorText(
        DWORD dwLastError
        )
    {
        HMODULE hModule = NULL; // default to system source
        LPSTR MessageBuffer;
        DWORD dwBufferLength;    DWORD dwFormatFlags = FORMAT_MESSAGE_ALLOCATE_BUFFER |
            FORMAT_MESSAGE_IGNORE_INSERTS |
            FORMAT_MESSAGE_FROM_SYSTEM ;    //
        // If dwLastError is in the network range, 
        //  load the message source.
        //    if(dwLastError >= NERR_BASE && dwLastError <= MAX_NERR) {
            hModule = LoadLibraryEx(
                TEXT("netmsg.dll"),
                NULL,
                LOAD_LIBRARY_AS_DATAFILE
                );        if(hModule != NULL)
                dwFormatFlags |= FORMAT_MESSAGE_FROM_HMODULE;
        }    //
        // Call FormatMessage() to allow for message 
        //  text to be acquired from the system 
        //  or from the supplied module handle.
        //    if(dwBufferLength = FormatMessageA(
            dwFormatFlags,
            hModule, // module to get message from (NULL == system)
            dwLastError,
            MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
            (LPSTR) &MessageBuffer,
            0,
            NULL
            ))
        {
            DWORD dwBytesWritten;        //
            // Output message string on stderr.
            //
            WriteFile(
                GetStdHandle(STD_ERROR_HANDLE),
                MessageBuffer,
                dwBufferLength,
                &dwBytesWritten,
                NULL
                );        //
            // Free the buffer allocated by the system.
            //
            LocalFree(MessageBuffer);
        }    //
        // If we loaded a message source, unload it.
        //
        if(hModule != NULL)
            FreeLibrary(hModule);
    }
    After you compile this program, you can insert the error code number as an argument and the program will display the text. For example:C:\> netmsg 2453
    Could not find domain controller for this domain
      

  5.   

    呵呵,我也想这样咧。问其他高人吧,论坛中搜索一下。Google 搜。
      

  6.   

    我想起来了 他用的 API 写的,没用控件.自己用API封一个类...就这么个办法.要不用别人写好的.