Click here to Skip to main content
15,890,512 members
Home / Discussions / C#
   

C#

 
GeneralRe: BHO's vs Firewalls Pin
Brian Delahunty4-Aug-04 23:22
Brian Delahunty4-Aug-04 23:22 
GeneralRe: BHO's vs Firewalls Pin
Stuggo5-Aug-04 0:26
Stuggo5-Aug-04 0:26 
GeneralRe: BHO's vs Firewalls Pin
Heath Stewart5-Aug-04 1:33
protectorHeath Stewart5-Aug-04 1:33 
GeneralRe: BHO's vs Firewalls Pin
Dave Kreskowiak5-Aug-04 7:43
mveDave Kreskowiak5-Aug-04 7:43 
GeneralWebSetup project Pin
Alex Getman4-Aug-04 21:41
Alex Getman4-Aug-04 21:41 
GeneralRe: WebSetup project Pin
Alex Getman4-Aug-04 22:18
Alex Getman4-Aug-04 22:18 
QuestionHow to get imported DLL handle Pin
fu04-Aug-04 18:08
fu04-Aug-04 18:08 
AnswerRe: How to get imported DLL handle Pin
Nick Parker4-Aug-04 18:38
protectorNick Parker4-Aug-04 18:38 
fu0 wrote:
i want to get the own.dll 's handle like LoadLibrary("own.dll") in VC++.
but HOW ?


[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);
[DllImport("unmanaged.dll")]
static extern int YourFunction(int i);
string path = @"..\somedir\own.dll";
IntPtr ptr = LoadLibrary(path);
int i = YourFunction(7);


In .NET 2.0 you will be able to do this:

[DllImport("kernel32.dll")]
internal static extern IntPtr LoadLibrary(String dllname);
[DllImport("kernel32.dll")]
internal static extern IntPtr GetProcAddress(IntPtr hModule, String procname);
internal delegate int MyMsgBox(IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)]String text, [MarshalAs(UnmanagedType.LPWStr)]String Caption, int type);
IntPtr user32 = LoadLibrary("user32.dll");
IntPtr procaddr = GetProcAddress(user32, "MessageBoxW");
MyMsgBox msgbox = (MyMsgBox)Marshal.GetDelegateForFunctionPointer(procaddr, typeof(MyMsgBox));
msgbox(IntPtr.Zero, "Hello, World", "A Test Run", 0);



- Nick Parker
My Blog | My Articles

GeneralRe: How to get imported DLL handle Pin
fu09-Aug-04 20:10
fu09-Aug-04 20:10 
Generaldebugging Pin
Sudee4-Aug-04 17:57
Sudee4-Aug-04 17:57 
GeneralRe: debugging Pin
Nick Parker4-Aug-04 18:06
protectorNick Parker4-Aug-04 18:06 
GeneralRe: debugging Pin
Sudee4-Aug-04 18:43
Sudee4-Aug-04 18:43 
GeneralC# use COM Pin
jiangweihz4-Aug-04 16:05
jiangweihz4-Aug-04 16:05 
GeneralRe: C# use COM Pin
Heath Stewart4-Aug-04 16:35
protectorHeath Stewart4-Aug-04 16:35 
Generaldisable the Task manager Pin
X20404-Aug-04 13:00
X20404-Aug-04 13:00 
GeneralRe: disable the Task manager Pin
eggie54-Aug-04 13:30
eggie54-Aug-04 13:30 
GeneralRe: disable the Task manager Pin
Colin Angus Mackay4-Aug-04 23:32
Colin Angus Mackay4-Aug-04 23:32 
GeneralRe: disable the Task manager Pin
eggie55-Aug-04 6:32
eggie55-Aug-04 6:32 
GeneralRe: disable the Task manager Pin
Colin Angus Mackay5-Aug-04 10:08
Colin Angus Mackay5-Aug-04 10:08 
Generalwindows service starts failed in Win2k Pin
tomc4-Aug-04 12:06
tomc4-Aug-04 12:06 
GeneralRe: windows service starts failed in Win2k Pin
Heath Stewart4-Aug-04 12:09
protectorHeath Stewart4-Aug-04 12:09 
GeneralRe: windows service starts failed in Win2k Pin
tomc4-Aug-04 12:21
tomc4-Aug-04 12:21 
GeneralRe: windows service starts failed in Win2k Pin
Heath Stewart4-Aug-04 16:37
protectorHeath Stewart4-Aug-04 16:37 
GeneralRe: Web.Config Pin
Nick Parker4-Aug-04 11:20
protectorNick Parker4-Aug-04 11:20 
GeneralRe: Web.Config Pin
tomc4-Aug-04 12:18
tomc4-Aug-04 12:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.