C# Marshall void* that is set to NULL -


trying write wrapper c dll.

the c native signature is:

bool winapi pbm_opencard (dword* cardhandle, tchar* cardname, void* module,          dword moduleid, word shareflags, word loadflags) 

to documentation says: "module set null - reserved"

this c# signature looks like:

public static extern  bool pbm_opencard(ref uint cardhandle,         stringbuilder cardname, system.intptr module, uint moduleid,         ushort shareflags, ushort loadflags)  

what pass in module argument in c# app? tried using system.intprt.zero , compiled, not sure if right way since can't interface hardware @ point.

your assumption correct, intptr.zero correspond c's null, don't forget set .net build away anycpu match arch of native method you're linking with.

protip: use [return: marshalas] attribute syntax set marshalling of bool system.boolean (though default, helps explicit). same applies parameters see it's using tchar (which makes me die inside).

protip 2: don't forget modify method signature conform .net style conventions, including not using underscores in identifiers, pascalcase publics , using camelcase parameter names. consider hiding native methods consumers , wrapping them in safe idisposable object.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -