I will use kernel32 dll in asp.net web application. This is the code: // Signature of the function pointer DllGetClassObject private delegate int DllGetClassObject (ref Guid ClassId, ref Guid InterfaceId, [Out, MarshalAs (UnmanagedType.Interface)] out object ppunk);
//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(); }
The problem is that when I call my GetTheDllHandle function, dllHandle returns zero
Has anyone done something similar there? Or does anyone have any suggestions?
Dhibi_mohanned
source share