从JNA / C调用DLL与Pascal的结果不一致

我有一个提供头文件的c ++ dll库,没有实现。 我为这个库函数实现了JNA调用。 我只有1个function的问题(其他,甚至类似的工作正常)。 这是来自.h文件的声明:

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 ); 

Java代码:

 public interface Dll extends StdCallLibrary { public String JNA_LIBRARY_NAME = "libname.dll"; int SMIMESignML(String pPin, int slot, String pOut, String pFrom, String pTo, String pSubject, String pHeaders, String pBody, String pAttachments, int flags, int init); } public class Test { private static final Dll dll = (Dll) Native.loadLibrary(Dll.JNA_LIBRARY_NAME, Dll.class, W32APIOptions.ASCII_OPTIONS); public static void main(String[] args) { String pOut = ""; String pFrom = ""; String pTo = ""; String pBody = ""; String pAttachments = ""; int code = dll.SMIMESignML(null, 0, pOut, pFrom, pTo, null, null, pBody, pAttachments, 0, 0); System.out.println(code); } } 

该函数应该返回不同的int错误代码,但它总是返回代码0xFFFF。

我可以用Pascal中的相同代码检查它:

 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. 

Pascal代码返回2,Java代码返回65535.此外,Pascal std调用工作正常,更改参数我们得到不同的错误代码(0 = OK和其他),但具有相同参数的Java不起作用,它总是返回0xFFFF。 如何调试它以了解问题?

PS此外,在同一个库中我有这个function,它可以从JNA运行,没有任何问题:

 int CALLINGCONV PKCS7SignML( const char *pin, unsigned long slot, const char* szInputFileName, const char* szOutputFileName, int bInitialize); 

操作系统是Win8 x64,JavaOracle7x86,库是x32。 “unsigned long”应该不是问题,因为它应该是4个字节的窗口。

如果同样的STD调用在这两个例子中返回不同的结果,我做错了什么? 我该如何调试呢?