C
Claire
How do I load and run dll functions dynamically please? The dll may be
anywhere and its location is set in a command line parameter.
I've loaded the dll OK, done the equivalent of GetProcAddress
// kernel32, not used dynamically as it's fixed location.
[DllImport("kernel32.dll")]
internal static extern IntPtr LoadLibrary(String dllname);
[DllImport("kernel32.dll")]
internal static extern IntPtr GetProcAddress(IntPtr hModule, String
procname);
// DynamicLibName is path/name of a dll on file system.
IntPtr Handle = LoadLibrary(DynamicLibName);
IntPtr GetError = GetProcAddress(Handle, "GetError");
If the function declaration for GetError is "int GetError(int ErrorNum" how
do I move on from the above to "return GetError(3);"
From old Delphi days I realize I must declare some kind of type, then link
it to the "GetError" procedure address. Im stuck on this bit.
I was following an example on a microsoft blog, they gave examples for a new
feature in the next version of dotnet - no good for my version. Their link
to a faq doing the same with version 1.1 required a userid and password, so
I was stuck.
Code or a link to a web site would be appreciated as I probably won't
understand a general overview of the process
anywhere and its location is set in a command line parameter.
I've loaded the dll OK, done the equivalent of GetProcAddress
// kernel32, not used dynamically as it's fixed location.
[DllImport("kernel32.dll")]
internal static extern IntPtr LoadLibrary(String dllname);
[DllImport("kernel32.dll")]
internal static extern IntPtr GetProcAddress(IntPtr hModule, String
procname);
// DynamicLibName is path/name of a dll on file system.
IntPtr Handle = LoadLibrary(DynamicLibName);
IntPtr GetError = GetProcAddress(Handle, "GetError");
If the function declaration for GetError is "int GetError(int ErrorNum" how
do I move on from the above to "return GetError(3);"
From old Delphi days I realize I must declare some kind of type, then link
it to the "GetError" procedure address. Im stuck on this bit.
I was following an example on a microsoft blog, they gave examples for a new
feature in the next version of dotnet - no good for my version. Their link
to a faq doing the same with version 1.1 required a userid and password, so
I was stuck.
Code or a link to a web site would be appreciated as I probably won't
understand a general overview of the process