-1
여기에 코드 조각입니다 :대표 및 기본 방법
private static bool CreateDelegates()
{
IntPtr ptr;
//--- SoundTouch: createInstance
ptr = Kernel32Methods.GetProcAddress (libHandle, "[email protected]");
if (ptr != IntPtr.Zero)
{
createInstance = (st_createInstance) Marshal.GetDelegateForFunctionPointer
(ptr, typeof (st_createInstance));
}
//--- SoundTouch: destroyInstance
ptr = Kernel32Methods.GetProcAddress (libHandle, "[email protected]");
if (ptr != IntPtr.Zero)
{
destroyInstance = (st_destroyInstance) Marshal.GetDelegateForFunctionPointer
(ptr, typeof (st_destroyInstance));
}
}
그리고 위의이 방법처럼 많은 assigments이있다. 할당량을 줄이기 위해 AssignProc (...)과 같은 메서드를 만들고 싶습니다. ?
private static st_createInstance createInstance;
[UnmanagedFunctionPointer (CallingConvention.StdCall)]
private delegate IntPtr st_createInstance();
도움말 : 내 생각
오류 : T.에 – zgnilec
@zgnilec을 위임을 Conver 유럽 수 없습니다 : 업데이트 된 코드와 설명을 참조하십시오. –
"return (T) Marshal ..."이 (가) 컴파일 될 수 없습니다. – zgnilec