Reputation: 216
dllManager.LoadFun(@"user32", "GetAsyncKeyState");
object tempFlag = dllManager.Invoke(ObjArray_Parameter, TypeArray_ParameterType, ModePassArray_Parameter, Type_Return, "GetAsyncKeyState");
r = (int)tempFlag;
llManager.UnLoadDll();
public void UnLoadDll()
{
FreeLibrary(hModule);
hModule = IntPtr.Zero;
farProc = IntPtr.Zero;
}
dllManager.UnloadDll()
does not seem to work, the memory is not released as when I call the DLL once again, it will continue to increase the memory. How do I release the memory?
Upvotes: 0
Views: 387
Reputation: 180908
In general, you declare an extern
function, and don't worry too much about memory usage. Windows uses this DLL internally anyway.
[DllImport("User32.dll")]
private static extern short GetAsyncKeyState(System.Windows.Forms.Keys key);
private void button1_Click(object sender, EventArgs e)
{
short state = GetAsyncKeyState(Keys.D);
switch (state)
{
// ?
}
}
See also
http://www.pinvoke.net/default.aspx/user32.getasynckeystate
Upvotes: 1
Reputation: 718
You can load that link library inside an Application Domain and then unload that application domain.
Upvotes: 0