GetProcAddress
-
I'm new to C# but not programming. I need to dynamically load dlls (native) and I have that part working with the [DllImport .... LoadLibrary ], and the with GetProcAddress. What I am having trouble with, is the returning value from GetProcAddress. I have it returning an IntPtr. It is valid and I assume I should be able to use it. In C++ I can cast the pointer to a function pointer. Is this possible in C#? I understand in .NET that function pointers are delegates and that you can't cast an IntPtr to a delegate type. So how do I go about calling the function that i have just obtained from a DLL? Thanx :) If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
-
I'm new to C# but not programming. I need to dynamically load dlls (native) and I have that part working with the [DllImport .... LoadLibrary ], and the with GetProcAddress. What I am having trouble with, is the returning value from GetProcAddress. I have it returning an IntPtr. It is valid and I assume I should be able to use it. In C++ I can cast the pointer to a function pointer. Is this possible in C#? I understand in .NET that function pointers are delegates and that you can't cast an IntPtr to a delegate type. So how do I go about calling the function that i have just obtained from a DLL? Thanx :) If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
This has been covered before in this forum. The most recent thread can be found at http://www.codeproject.com/script/comments/forums.asp?msg=890289&forumid=1649#xx890289xx[^]. This was found quickly by searching for "LoadLibrary" after clicking "Search comments" above.
Microsoft MVP, Visual C# My Articles
-
This has been covered before in this forum. The most recent thread can be found at http://www.codeproject.com/script/comments/forums.asp?msg=890289&forumid=1649#xx890289xx[^]. This was found quickly by searching for "LoadLibrary" after clicking "Search comments" above.
Microsoft MVP, Visual C# My Articles
1. why would I search when I know that Heath Stewart answers questions on this forum within 20 mins? ;P 2. I did actually search and find that, but that tells me that it'll be available in .NET 2.0. I thought maybe someone had a work around for pre 2.0. There's gotta be some guru out there that has done it ? If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
-
1. why would I search when I know that Heath Stewart answers questions on this forum within 20 mins? ;P 2. I did actually search and find that, but that tells me that it'll be available in .NET 2.0. I thought maybe someone had a work around for pre 2.0. There's gotta be some guru out there that has done it ? If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
1. Because you are an idiot then. :doh: top secret xacc-ide 0.0.1
-
1. why would I search when I know that Heath Stewart answers questions on this forum within 20 mins? ;P 2. I did actually search and find that, but that tells me that it'll be available in .NET 2.0. I thought maybe someone had a work around for pre 2.0. There's gotta be some guru out there that has done it ? If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
1. Because you always should search first. Good research is required skill for any good developer, and with forums like you have here today it's so easy compared to when I first started programming (no web; only gopher). 2. Nick did provide a work around that does work (though P/Invoking
LoadLibrary
really isn't necessary unless you want to check whether or not the DLL was actually loaded successfully since invoking the imported function won't tell you). Using theDllImportAttribute
, the CLR will load the referenced DLL when necessary. You should still be able to unload it.Microsoft MVP, Visual C# My Articles
-
1. Because you are an idiot then. :doh: top secret xacc-ide 0.0.1
Leppie, thats a little harsh isn't it? p.s. I wasn't the one that gave you the 1. For something as intelligent as your comment, it isn't worth it. Jubjub If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson
-
1. Because you always should search first. Good research is required skill for any good developer, and with forums like you have here today it's so easy compared to when I first started programming (no web; only gopher). 2. Nick did provide a work around that does work (though P/Invoking
LoadLibrary
really isn't necessary unless you want to check whether or not the DLL was actually loaded successfully since invoking the imported function won't tell you). Using theDllImportAttribute
, the CLR will load the referenced DLL when necessary. You should still be able to unload it.Microsoft MVP, Visual C# My Articles
Thanx for your help Heath. Much appreciated. If there's one thing I've learned, it's that life is one crushing defeat after another until you just wish Flanders was dead. - Homer Simpson