我想在MediaInfo.dll中调用一个函数。
功能是:
const wchar_t* __stdcall MediaInfo_Option (void* Handle, const
wchar_t* Option, const wchar_t* Value);
我已经用这种方式在c#代码中声明了它:
[DllImport("MediaInfo.dll", CharSet = CharSet.Unicode)] internal
static extern string MediaInfo_Option(IntPtr Handle, string OptionString, string Value);
这里是它被称为的代码:
MediaInfo.MediaInfo_Open(this.h, path);
MediaInfo.MediaInfo_Option(this.Handle, "Complete", "1");
myTextBox.Text = MediaInfo.MediaInfo_Inform(this.h, 0);
MediaInfo.MediaInfo_Close(this.h);
问题是,在调用该函数时,使用.NET Framework等于或大于版本4编译的任何c#应用程序都会崩溃。
我该如何解决?
提前致谢。
答案 0 :(得分:0)
You did not Marshall the wchar_t* of both input and output, you'll get random errors.
There is a C# binding of MediaInfo which takes care of all the ugly stuff.
You can use it with a C# example of MediaInfo.
You may be interested in downloading the DLL package with a C# example project.