Proper calling convention of unmanaged DLL function

前端 未结 1 416
南旧
南旧 2021-01-15 20:56

I\'m trying to write a bare-bones ultra-simple light-weight wrapper for the LibVLC DLL Library. I don\'t need access to much, just the ability to play pause and stop media f

相关标签:
1条回答
  • Not much point in declaring the argument type if only NULL is permitted. Just declare it IntPtr and pass IntPtr.Zero.

    The debugger is pointing out that you forgot to declare the CallingConvention. It is not the default for .NET, this is a __cdecl function. So the proper declaration would be:

    [DllImport("libvlc", EntryPoint = "libvlc_new", 
         CallingConvention = CallingConvention.Cdecl)]
    public static extern IntPtr New(int argc, IntPtr argv);
    

    Called as:

    New(0, IntPtr.Zero);
    

    Do try to pick a better name...

    0 讨论(0)
提交回复
热议问题