sách gpt4 ăn đã đi

c# - 从传递字节数组的 C# 调用 delphi dll 函数

In lại 作者:太空狗 更新时间:2023-10-29 21:51:48 24 4
mua khóa gpt4 giày nike

我无法找出让 delphi 函数对 .net 中的字节数组进行操作的最佳方法。

delphi 签名如下所示:

procedure Encrypt(
var Bytes: array of byte;
const BytesLength: Integer;
const Password: PAnsiChar); stdcall; export;

C# 代码如下所示:

[DllImport("Encrypt.dll",
CallingConvention = CallingConvention.StdCall,
CharSet = CharSet.Ansi)]
public static extern void Encrypt(
ref byte[] bytes,
int bytesLength,
string password);

在字节数组声明之前省略 của chúng tôitham khảo 似乎失败了,但这是必需的,因为我将只更改数组的内容而不是数组本身?

此外,出于某种原因,我似乎无法在 delphi 中获取数组的长度,如果我删除 BytesLength 参数,那么 Length(Bytes) 将不会工作,如果我添加 BytesLength 参数,Length(Bytes) 开始工作,但 BytesLength 的值错误。

câu trả lời hay nhất

将 Delphi Encrypt 的第一个参数设置为 Bytes: PByte 就可以了。

一个开放数组,正如您所拥有的,期望传递指向第一个元素的指针和解释您在问题中描述的内容的长度。

关于c# - 从传递字节数组的 C# 调用 delphi dll 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6933386/

24 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress