我在 C# 中加载了一个具有依赖关系的 MFC dll(假设我正在加载依赖于 C.dll、B.dll 和 A.dll 的 D.dll)。这是我的代码:
[DllImport( "kernel32.dll", CharSet = CharSet.Auto, SetLastError = true )]
static extern IntPtr LoadLibrary( string lpFileName );
private void btn_Click( object sender, EventArgs e )
{
int nUltErr;
string strDLL;
StringBuilder strPDF;
StringBuilder strXML;
strDLL = "C:\\DEVELOP\\Libs\\Interfaccia\\Interfaccia_C_2005\\DLL\\Interfaccia_C_2005.dll";
strFile1 = new StringBuilder( @"C:\DEVELOP\Libs\Interfaccia\TestCase\PROGRAM\tiger.pdf" );
strFile2 = new StringBuilder( @"C:\DEVELOP\Libs\Interfaccia\TestCase\PROGRAM\tiger.XML" );
if( LoadLibrary( strDLL ) != IntPtr.Zero )
{
LoadPDF( strPDF );
SaveXML( strXML );
ClosePDF();
FreeMemory();
}
else
{
nUltErr = Marshal.GetLastWin32Error();
MessageBox.Show( "Errore nel caricamento della dll." );
}
}
nUltErr 是 1008 = 0x3F0,应该是 ERROR_NO_TOKEN。这在 C# 中到底是什么意思?DLL 的路径是正确的。