Managed/Unmanaged

C#の配列をポインタ配列にして,Cの関数にポインタを渡す.

C#側 unsafe public static void hogecs() { short[] wave_data = new short[44100]; for (int i = 0; i < 44100; i++) { wave_data[i] = (short)(30000 * Math.Sin(2 * Math.PI * 440 * i / 44100)); } fixed (short* ptr = &wave_data[0]) { dll.Class1.ho…

C#での配列をポインタ配列に

配列にポインタ・アクセスする http://www.atmarkit.co.jp/fdotnet/csharp_abc/csharp_abc_021/csharp_abc03.html

pure CのDLLから呼び出し元C#へのコールバック

///pure C DLL #include "windows.h" #define DLLEXPORT __declspec(dllexport) extern "C" { DLLEXPORT int __stdcall MyFunc(int (*callback)()) { return callback(); } } ///C# class DLL { [DllImport"hoge.dll", CallingConvention = CallingConventio…