0

Function in Delphi is -

FuncName: PAnsiChar (stdcall)

I don't know the rest of the function code, cause i can't open the Dll.

And i tried to implement it to C# like this -

[DllImport("Lib2-2-1.dll", EntryPoint = "FuncName", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
        [return: MarshalAs(UnmanagedType.AnsiBStr)]
        public static extern string FuncName();

when i'm trying to call this C# function in code - everything just closes without an Error, and the code stops executing. Could someone help me please and explain how to write it properly.

And another thing. I tried to open this Dll in DotPeek but it won't open and it says - Not supported, could someone please explain how can i view the code inside it.

vovobot
  • 11
  • 3

1 Answers1

1

okey

so, here is the answer, i found it in this question thread here is the importing from Dll

[DllImport("Lib2-2-1.dll", EntryPoint = "FuncName", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
    [MethodImplAttribute(MethodImplOptions.PreserveSig)]
    public static extern IntPtr FuncName();

And this how to call it

IntPtr ptr = FuncName();
string result = Marshal.PtrToStringAnsi(ptr);
vovobot
  • 11
  • 3