小编Mik*_*ike的帖子

从c#调用dll中的Delphi方法

我试图使用以下签名调用Delphi DLL中的方法:

 function SMap4Ovr(const OverFileName       : ShortString    ;
                    const Aclay              : Integer        ;
                    const Acarbon            : Double         ;
                    out   errstr             : ShortString): WordBool;
Run Code Online (Sandbox Code Playgroud)

我在C#中使用以下导入:

        [DllImport("SMap.dll", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
    public static extern bool SMap4Ovr(
        string OverFileName,
        int Aclay,
        double Acarbon,
        out string errstr
        );
Run Code Online (Sandbox Code Playgroud)

但我得到一个AccessViolationException.

我似乎能够调用DLL中的几个更简单的方法,这些方法有字符串参数但不是int或double.

我也试过CallingConvention = CallingConvention.Cdecl,但这给了我同样的错误.

c# delphi pinvoke

5
推荐指数
1
解决办法
4717
查看次数

标签 统计

c# ×1

delphi ×1

pinvoke ×1