Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/156.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ win32 dll函数的std调用在Pascal和c+中有所不同+;_C++_Dll_Pascal_Stdcall - Fatal编程技术网

C++ win32 dll函数的std调用在Pascal和c+中有所不同+;

C++ win32 dll函数的std调用在Pascal和c+中有所不同+;,c++,dll,pascal,stdcall,C++,Dll,Pascal,Stdcall,我有带此函数的C dll: int CALLINGCONV SMIMESignML( const char* pin, unsigned long slot, const char* szOutputFilePath, const char* szFrom, const char* szTo, const char* szSubject, const char* szOtherHeaders, const char* szBody, const char* s

我有带此函数的C dll:

int CALLINGCONV SMIMESignML(
  const char* pin,
  unsigned long slot,
  const char* szOutputFilePath,
  const char* szFrom,
  const char* szTo,
  const char* szSubject,
  const char* szOtherHeaders,
  const char* szBody,
  const char* szAttachments,
  unsigned long dwFlags,
  int bInitialize
);
呼叫CONV是一种呼叫方式。 我用C++称之为:

#include "stdafx.h"
#include "windows.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[]) {
  HMODULE lib = LoadLibrary(_T("libname.dll"));
    typedef int(__stdcall  *FNPTR)(const char* pPin, unsigned long slot, 
      const char* pOut, const char* pFrom, const char* pTo, 
      const char* pSubject, const char* pHeaders, const char* pBody, 
      const char* pAttachments, unsigned int flags, int init);
  FNPTR myfunc = (FNPTR)GetProcAddress(lib, "SMIMESignML");
  if (!myfunc) {
    printf("No function!\n");
  } else {
    int code = myfunc(NULL, 0, "", "", "", NULL, NULL, "", "", 0, 0);
    cout << code << endl;
  }
  return 0;
}
正如预期的那样,它返回2。 为什么相同的呼叫行为不同?有什么区别

<操作系统是Win 8x64,编译C++代码时使用VS2013,LIB DLL为32位。 与此相关的问题是: 但是这个问题不包括范围内的JNA和JAVA


遗憾的是,我没有DLL库的来源,只有一些头文件。< /P>你是编译C++程序作为32位还是64位?主动的解决方案平台是Wi32 WHOWE是“代码> CalpIn CONV</代码>?它被定义为“函数”,在函数指针声明中没有明显的错误。不让它与函数声明匹配是没有意义的,但是类型足够兼容。选择合适的武器是电话,你需要知道错误代码是什么意思。你是不是把C++程序编译成32位或64位?主动的解决方案平台是Wi32 WHOWE是“代码> CalpIn CONV</代码>?它被定义为“函数”,在函数指针声明中没有明显的错误。不让它与函数声明匹配是没有意义的,但是类型足够兼容。正确的选择武器是电话,你真的需要知道错误代码是什么意思。
unit dll;
interface
const
  JNA_LIBRARY_NAME = 'libname.dll';

function SMIMESignML(pPin: PChar; slot: integer; pOut: PChar; pFrom: PChar; pTo: PChar;
  pSubject: PChar; pHeaders: PChar; pBody: PChar; pAttachments: PChar; flags: integer;
  init: integer): integer; stdcall; external JNA_LIBRARY_NAME;
implementation
end.

program Hello;
uses dll;
var 
  code: integer;
begin
  code := SMIMESignML(nil, 0, '', '', '', nil, nil, '' , '', 0, 0);
  writeln(code);
end.