On Monday, 16 March 2015 at 10:02:46 UTC, Rikki Cattermole wrote:

So instead of writing:

extern(Windows) DWORD GetVersion(),

we can write:

extern(Windows, "api-ms-win-core-sysinfo-l1-2-1.dll", [optional
funcname]) DWORD GetVersion() or
extern(Windows, "kernel32.dll") DWORD GetVersion() for older Windows
versions (<8).


I know probably a mixin will partially solve this, but this will save some important boilerplate code (just look at DerelictOrg bindings,
thousands LOC just to load some functions from a dll).


Don't, please don't dare me...
I could totally do this with UDA's and CTFE for function pointers. Plus my new total secret API could make this trivial to hook into.

Been there, done that: https://github.com/rumbu13/sharp/blob/master/src/system/runtime/interopservices/package.d

alias GetVersion = DllImport!("api-ms-win-core-sysinfo-l1-2-1.dll", "GetVersion", DWORD function())

I didn't achieve more than that, i consider this ugly, non-intellisense friendly, that's whay a builtin language construct will be better. Can't wait to see your total super secret API :)

Reply via email to