2

我有一个 c++ 函数,例如,

extern "C" __declspec ( dllexport ) DWORD GetSizeAfterMergeISOTemplates(BYTE* StoredISOTemplate, BYTE* CapturedISOTemplate)
{
}

我想在合并参数中的两个字节数组后返回数组的大小。c++ 部分正在工作并返回正确的值。

但我的问题是我需要在 c# 中获取 DWORD 中的值。功能是,

   [DllImport("XFPLibISO")]
        extern static UInt32 GetSizeAfterMergeISOTemplates(Byte[] StoredISOTemplate, Byte[] CapturedISOTemplate);

但它返回错误的值。它的3477800东西。但实际值在 964 左右。

有人可以建议我该怎么做吗?

4

1 回答 1

4

您提供的 C++ 函数表示CallingConvention.Cdecl。您必须在申请时指定它DllImportAttribute

[DllImport("XFPLibISO", CallingConvention = CallingConvention.Cdecl)]
于 2012-06-01T10:00:31.447 回答