Delphi 7:
         Function OpenComm(nComm:BYTE;nBaud:integer):integer; stdcall; far; External 'DllCom.dll';
         执行正常
而在VC2003 :
         typedef  unsigned  char  (CALLBACK* LPOpenComm)(unsigned  char nComm,long  nBaud);        hDLL = LoadLibrary(".\\DllCom.dll");   LPOpenComm LPOpenComm1;    
    LPOpenComm1 = (LPOpenComm)GetProcAddress(hDLL,"OpenComm");     uReturnVal = LPOpenComm1(1, 9600);     在执行最后一句时,出错:大概说是参数或返回值不对
      应该如何在VC2003中进行定义?

解决方案 »

  1.   

    其他的不知道, 但很明显的错误: typedef unsigned char 与 integer 不相符...
      

  2.   

    把 typedef unsigned char 改为typedef int 还是不对
      

  3.   

    typedef INT (WINAPI* OpenComm)(BYTE nComm, INT nBaud);
      

  4.   

    按是上面改后,仍出现如下错误:
       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 daclared with a different calling convention