그는 모두
관리되지 않는 dll에서 C #의 관리되는 dll로 만들고 싶습니다.
문서에서는 다음과 같습니다.
typedef void* AP_HANDLE
typedef uint32_t ap_u32
AP_HANDLE ap_CreateVirtual(const char *szFilename)
void ap_SetState(AP_HANDLE apbase, const char *szState, int nValue)
unsigned char *ap_ColorPipe(AP_HANDLE apbase,
unsigned char *pInBuffer,
ap_u32 nInBufferSize,
ap_u32 *rgbWidth,
ap_u32 *rgbHeight,
ap_u32 *rgbBitDepth)
C ++에서는 잘 작동하지만 C #에서는 구문이 문제입니다. evan이 첫 번째 함수로 작동하도록 만들 수없는 것 같습니다.
public unsafe class appbase
{
[DllImport("D:\\apbase.dll", EntryPoint = "ap_CreateVirtual")]
//, CharSet = UnicodeEncoding
//, CallingConvention = CallingConvention.StdCall
public static extern void* ap_CreateVirtual(char* szFilename);
}
과
public static void Main()
{
unsafe
{
void* ap_handle = null;
appbase APPbase = new appbase();
string s = "D:\\ASX.xsdat";
fixed (char* p = s)
{
ap_handle = APPbase.ap_CreateVirtual(p);
}
return;
}
}
ap_CreateVirtual 문자열, String *, char *, char []에 대한 인수로 시도하고 반환시 중단 점을 두었습니다. ap_handle은 항상 0x0000 값이었습니다.
이러한 함수를 가져 오는 적절한 방법은 무엇입니까?
char*
.NET 문자열의 기본 마샬링입니다.
[DllImport("D:\\apbase.dll", EntryPoint = "ap_CreateVirtual", CharSet = CharSet.Ansi)]
//, CallingConvention = CallingConvention.StdCall
public static extern System.IntPtr ap_CreateVirtual(string szFilename);
char
C #에서 C ++가 wchar_t
아닌 C ++ 이기 때문에 원래 시도가 잘못되었습니다 char
.
char
C #에서 C ++가 필요한 경우 byte
또는 sbyte
. 그러나 p / invoke는 단순히 System.String
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다