我用VC写了一个DLL,是这样导出的:
_declspec(dllexport) unsigned char WINAPI GetPath(LPGUID pGuid, char* DevPath);但是我用C++ Builder调用时
必须要用
FARPROC Proc = GetProcAddress(Library, "?GetPath@@YAEPAU_GUID@@PAD@Z");
这样莫名其妙的名称才可以找到 GetPath 函数怎样才可以让C++ Builder调用时可以直接用 "GetPath" 名称来引用 GetPath 函数呢?麻烦各位高手。

解决方案 »

  1.   

    _declspec(dllexport)前面加上extern "C"
      

  2.   

    但是还是要出现
    "_GetPath@8"
    这样的名称
      

  3.   

    在你的dll源代码模块中加上:
    #pragma comment(linker,"/export:GetPath=_GetPath@8")
      

  4.   

    WINAPI改成_cdecl就可以啦dll有三种调用约定:他们的参数进栈顺序,出栈调用,输出函数符号都会有所不同
    1、_stdcall(WINAPI),也就是pascal调用,output:_GetPath@8
    2、_cdecl,output:_GetPath,前面加_declspec(dllexport)则会去掉"_",output:GetPath
    3、_fastcall