C#からC++の関数を呼ぶ 文字列が引数のとき
以下でうまくいく。
【C++ソース】
extern "C" { __declspec(dllexport) void Resize(const char* file_path, double fx, double fy ); __declspec( dllexport ) void Print(const char* str); }
【C#ソース】
[DllImport("OpenCV.dll")] static extern void Resize(string str, double fx, double fy); [DllImport("OpenCV.dll")] static extern void Print(string str); static void Main() { Print("test!"); string file_path = "src.jpg"; Resize(file_path, 0.5, 0.5); System.Console.WriteLine("end."); }