小编Jul*_*cki的帖子

本机 DLL - C#

我有用 Delphi 编写的本机 DLL 库。我想从 C# 引用这个库并获取返回的字符串。

功能

function GetCode (aUser,aPassword: PAnsiChar): PAnsiChar; stdcall;
Run Code Online (Sandbox Code Playgroud)

C# 代码

[DllImport("C:\\library.dll", CallingConvention = CallingConvention.StdCall,
        CharSet = CharSet.Ansi)]
private static extern String GetCode([MarshalAs(UnmanagedType.LPStr)]string aUser, [MarshalAs(UnmanagedType.LPStr)]string aPassword);

public String getCode(String login, String password) {
        return GetCode(login, password);
}
Run Code Online (Sandbox Code Playgroud)

尝试调用函数应用程序退出,代码为-1073740940 (0xc0000374)。

你有过期吗?谢谢你的帮助

c# delphi dll

2
推荐指数
1
解决办法
359
查看次数

标签 统计

c# ×1

delphi ×1

dll ×1