7
我將在asp.net web應用程序中使用kernel32 dll。這是代碼: // DllGetClassObject函數指針簽名 private delegate int DllGetClassObject(ref Guid ClassId,ref Guid InterfaceId,[Out,MarshalAs(UnmanagedType.Interface)] out object ppunk);來自kernel32.dll的函數LoadLibrary在Asp web應用程序中返回零。
//Some win32 methods to load\unload dlls and get a function pointer
private class Win32NativeMethods
{
[DllImport("kernel32.dll", CharSet=CharSet.Ansi)]
public static extern IntPtr GetProcAddress(IntPtr hModule, string lpProcName);
[DllImport("kernel32.dll")]
public static extern bool FreeLibrary(IntPtr hModule);
[DllImport("kernel32.dll")]
public static extern IntPtr LoadLibrary(string lpFileName);
}
public string GetTheDllHandle (dllName)
{
IntPtr dllHandle = Win32NativeMethods.LoadLibrary(dllName); // the dllHandle=IntPtr.Zero
return dllHandle.ToString();
}
,當我打電話給我的功能GetTheDllHandle,該dllHandle返回零
有沒有人在那裏做一些類似的問題?還是有人有任何建議?
可能是該DLL不存在,你認爲它沒有,可能是配股,可能是別的東西完全。調用GetLastError來找出。 –