TooTallNate / ref

Turn Buffer instances into "pointers"
http://tootallnate.github.com/ref
453 stars 141 forks source link

force type conversion #65

Closed tinysec closed 7 years ago

tinysec commented 7 years ago

in windows , like function UnregisterClassA https://msdn.microsoft.com/en-us/library/windows/desktop/ms644899(v=vs.85).aspx

BOOL WINAPI UnregisterClassA( In LPSTR lpClassName, _Inopt HINSTANCE hInstance );

the param 'lpClassName' can accept both a string or a ushort param.

like
UnregisterClassA( "MyClass" , hInstance); or UnregisterClassA( (char*)31756 , hInstance);

"The atom must be in the low-order word of lpClassName; the high-order word must be zero."

but can only define the proxy routine once , like

var user32 = ffi.Library( "user32.dll" , { "UnregisterClassA" : [ wtypes.BOOL , [ wtypes.LPSTR , // in LPSTR lpClassName wtypes.HINSTANCE // in HINSTANCE hInstance ], ], };

what should i do , that can support this c-like force type conversion

tinysec commented 7 years ago

finaly i use