Hi I am using COM Class and loading it in browser.

I am calling LoadLibrary of kernel32 but it returns me zero.

I have also tried using LoadLibraryEx which gives me pointer to DLL but when I call any function of that dll it gives me Attempt to read or write protected memory.

<DllImport("kernel32.dll", EntryPoint:="LoadLibraryEx")> _
    Public Shared Function LoadLibraryEx(ByVal lpLibFileName As String, ByVal hint As IntPtr, ByVal hparam As UInteger) As IntPtr
    End Function

<UnmanagedFunctionPointer(CallingConvention.StdCall, CharSet:=CharSet.Unicode)> _
    Public Delegate Function LoadIdcardLibrary() As Integer

Dim lb As IntPtr = LoadLibraryEx("\idcarddll.dll", IntPtr.Zero, 8)
i = Marshal.GetDelegateForFunctionPointer(pb, GetType(LoadIdcardLibrary)).DynamicInvoke()

Thanks in advance

Recommended Answers

All 2 Replies

>I am calling LoadLibrary of kernel32 but it returns me zero.

Because it fails to load due to lack of privileges.

>I am calling LoadLibrary of kernel32 but it returns me zero.

Because it fails to load due to lack of privileges.

How to set privileges to load dll file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.