我在调用一个DLL时出现了一个错误,具体如下,
————源程序—————
#include <stdio.h>
#include <windows.h>
void main(void)
{
typedef void (*pFECOM_GetDLLVersion)(char* cVersion);
int iBack;
char cVersion[256];
HINSTANCE hDll;
pFECOM_GetDLLVersion FECOM_GetDLLVersion;
hDll=LoadLibrary("FECOM.DLL");
FECOM_GetDLLVersion=(pFECOM_GetDLLVersion)GetProcAddress(hDll,"FECOM_GetDLLVersion");
FECOM_GetDLLVersion(cVersion);
printf("版本为%s\n",cVersion);
FreeLibrary(hDll);
}
————以上是的原代码———其中FECOM.DLL是一个硬件厂商提供的操作硬件的文件,其中FECOM_GetDLLVersion(cVersion)函数的功能是通过参数返回版本信息,该函数具体说明如下:Function
Gets the version number of the DLLSyntax
 void FECOM_GetDLLVersion(char* cVersion)Description
The function returns the version number of the DLL.
cVersion is an empty, null-terminated string for returning the version number. The
string should be able to hold at least 256 characters.
In the current version the string is filled with “02.00.01”. Newer versions may
provide additional information.Return value
noneExample
#include “fecom.h”
...
...
char cVersion[256];
FECOM_GetDLLVersion(cVersion)
// code here for displaying version number
————————————————————————————————————————————我的程序执行后产生的问题是跳出一个对话框提示:
Debug Error!Program:...rosoft Visual Studio\...\Debug\TestFecom.exe
Module:
File: i386\chkesp.c
Line:42The value of ESP was not properly saved across a function.This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
...我按了“忽略”按钮后其实可以得到版本信息,但不知道为什么每次都会产生这个错误提示,请高手帮忙一下,谢谢!

解决方案 »

  1.   

    typedef   void   __stdcall (*pFECOM_GetDLLVersion)(char*   cVersion); 
      

  2.   

    typedef       void       __stdcall   (*pFECOM_GetDLLVersion)(char*       cVersion);   syntax 
    ————————————————————————————————————————
    oyljerry 你好,使用了你的方法后,编译时出现了一个错误(之前编译是无错误的),如下,
    出错位置,FECOM_GetDLLVersion=(pFECOM_GetDLLVersion)GetProcAddress(hDll,"FECOM_GetDLLVersion");
    错误提示,error : missing ';' before identifier 'GetProcAddress'
    希帮忙,谢谢!
      

  3.   

    上面说漏了,总共是4个错误,
    C:\Program Files\Microsoft Visual Studio\MyProjects\TestFeCom\Test.cpp(5) : error C2059: syntax error : '('
    C:\Program Files\Microsoft Visual Studio\MyProjects\TestFeCom\Test.cpp(9) : error C2065: 'pFECOM_GetDLLVersion' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\TestFeCom\Test.cpp(9) : error C2146: syntax error : missing ';' before identifier 'FECOM_GetDLLVersion'
    C:\Program Files\Microsoft Visual Studio\MyProjects\TestFeCom\Test.cpp(9) : error C2065: 'FECOM_GetDLLVersion' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\TestFeCom\Test.cpp(11) : error C2146: syntax error : missing ';' before identifier 'GetProcAddress'
      

  4.   

    查了一下其他帖子,自己解决了
    typedef       void       __stdcall   (*pFECOM_GetDLLVersion)(char*       cVersion);  
    应该是
    typedef       void      ( __stdcall   *pFECOM_GetDLLVersion)(char*       cVersion);