2016-11-11 11 views
1

I以下のC++の機能を持っていると私は、C#でラッパー関数になるだろう:私はそうしようとしたラップC++の関数ポインタ

byte* FunctionReturnVectorPoint() 
{ 
    return vectorPoint; 
} 

[DllImport("DLL_NAME.dll", CallingConvention = CallingConvention.ThisCall)] 
unsafe public static extern byte*[] FunctionReturnVectorPoint(); 

でも動作しません。

ご意見はありますか?

+1

それはあなたの呼び出し規約が正しくない – Ross

+0

動作しない理由を説明する必要があります。詳細については、[MSDN](https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.callingconvention(v = vs.110).aspx)を参照してください。 – Nikita

+0

私はこれに変更しました:[DllImport( "DLL_NAME.dll"、CallingConvention = CallingConvention.Cdecl)]public static extern IntPtr FunzioneC(); –

答えて

1

は解決:

[DllImport("DLL_NAME.dll", CallingConvention = CallingConvention.ThisCall)] 
public static extern IntPtr FunctionReturnVectorPoint(); 

、このように関数を呼び出す:

IntPtr tempPoint = FunctionReturnVectorPoint(); 
byte[] vector= new byte[dimensionVector]; 
Marshal.Copy(tempPoint , vector, 0, dimensionVector);