I want to load Win32 API functions using Runtime.loadLibrary and GetProcAddress(...) . Using mixin :
template GetProcA(alias func, alias name_in_DLL) { const char[] GetProcA = func ~ ` = cast(typeof(`~func~`)) GetProcAddress(hModule,"`~name_in_DLL~`");`; } ... static extern (Windows) Object function (HWND hWnd, int nIndex) GetWindowLong; static extern (Windows) Object function (HWND hWnd, int nIndex, Object dwNewLong) SetWindowLong;
I can create an instance (in the class constructor) as follows:
mixin GetProcA!("SetWindowLong", "SetWindowLongA");
but if you use it again for another function:
mixin GetProcA!("GetWindowLong", "GetWindowLongA");
the compiler complains:
mixin GetProcA!("GetWindowLong","GetWindowLongA") GetProcA isn't a template...
I do not see the point: if the first instance created GetProcA , and I can not use it again, since it helps me?
source share