C#을 사용하여 관리되지 않는 코드를 호출하려고합니다.C# 비 관리 코드 호출
extern "C" __declspec(dllexport) LPBYTE DataReceived(LPBYTE signals)
{
LPBYTE test;
*(WORD*)(test) = 0x0C;
*(WORD*)(test + 2) = 0x1000;
return test;
// I even tried returning 0x00 only; and I was still getting the exception
}
내가 잘 int 값을 반환하는 다른 기능을 데
internal sealed class Test
{
[DllImport("testlib.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern byte[] DataReceived(byte[] signals);
}
// signals is byte[] too
byte[] foo = Test.DataReceived(signals);
//exception that occurs
A first chance exception of type 'System.Runtime.InteropServices.MarshalDirectiveException
C# 코드, 나는 자신을 LPBYTE 관련 같아요. 어떤 도움을 주시면 감사하겠습니다. 정확히이 함수의 반환 값이 무엇인지 :
훌륭하게 작동합니다. 고맙습니다. – unmanageddude