大概的代码如下,大家帮忙解决一下,谢谢啦
调用TEST.DLL的程序如下
typedef bool (*PFN_test)(LPCTSTR first,LPCTSTR second,BOOL bFailIf);
int _tmain(int argc, TCHAR* argv[])
{
  
HINSTANCE hinstDLL; 
PFN_test  test1; 
BOOL fFreeDLL; 
hinstDLL = LoadLibrary("test.dll"); 
        if (hinstDLL != NULL) 
 { 
    test1= (PFN_test) GetProcAddress(hinstDLL, "test1"); 
    if (test1 != NULL) 
    printf("ok"); 
    fFreeDLL = FreeLibrary(hinstDLL); 
         } }
编译后出现错误:
test.dll warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
test.dll error C2018: unknown character '0x3'
test.dll error C2018: unknown character '0x4'
test.dll error C2018: unknown character '0x40'
test.dll error C2018: unknown character '0xe'
……………………
如此的错误一百多个dll的主要代码test.cpp如下
#include "stdafx.h"
#include "test.h"
#include <shlwapi.h> 
#pragma comment( lib, "shlwapi.lib") #ifdef _MANAGED
#pragma managed(push, off)
#endifBOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
 )
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
    return TRUE;
}#ifdef _MANAGED
#pragma managed(pop)
#endiftest_API int fntest(void)
{
return 42;
}// This is the constructor of a class that has been exported.
// see test.h for the class definition
Ctest::Ctest()
{
return;
}//自己的函数,需要调用的函数
bool geterror()
{
}
bool test1(LPCTSTR first,LPCTSTR second,BOOL bFailIfExists)
{
}

解决方案 »

  1.   

    我把所有中文都去掉了,包括获取系统错误返回的中文
    还是有很多错误
    1>test.dll : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
    1>test.dll(1) : error C2018: unknown character '0x3'
    1>test.dll(1) : error C2018: unknown character '0x4'
    1>test.dll(1) : error C2018: unknown character '0x40'
    1>test.dll(1) : error C2018: unknown character '0xe'
    1>test.dll(1) : error C2018: unknown character '0x1f'
    1>test.dll(1) : error C2146: syntax error : missing ';' before identifier ''
    1>test.dll(1) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>test.dll(1) : error C2143: syntax error : missing ';' before '?'
    1>test.dll(1) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2143: syntax error : missing ';' before '}'
    1>test.dll(2) : error C2059: syntax error : '}'
    1>test.dll(2) : error C2018: unknown character '0x14'
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2018: unknown character '0x1c'
    1>test.dll(2) : error C2018: unknown character '0x13'
    1>test.dll(2) : error C2015: too many characters in constant
    1>test.dll(2) : error C2018: unknown character '0x3'
    1>test.dll(2) : error C2018: unknown character '0x1f'
    1>test.dll(2) : error C2014: preprocessor command must start as first nonwhite space
    1>test.dll(2) : error C2018: unknown character '0x1e'
    1>test.dll(2) : error C2014: preprocessor command must start as first nonwhite space
    1>test.dll(2) : warning C4819: The file contains a character that cannot be represented in the current code page (936). Save the file in Unicode format to prevent data loss
    1>test.dll(2) : fatal error C1004: unexpected end-of-file found
      

  2.   

    你copy别人的代码导致的。
      

  3.   

    简单的方法是,新建一个cpp文件,重新敲一边吧。
      

  4.   

    用2进制编辑器打开,看看肯定有>0x80的字符,删掉这些字符和紧跟后面的一个字符。(宽字符一般2字节)
      

  5.   

    你的代码是从网页上复制下来的,里面有特殊字符,把源文件储存为Unicode格式就没问题了,或者你把这些特殊字符都找出来改掉。
      

  6.   

    2进制编辑器,vc.net上有有吗?还是需要自己下载?
      

  7.   

    编译终于通过了,但是出了新问题
    提示Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call.  This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.