c# - Calling functions from Unmanaged DLL -
i have unmanaged dll following functions:
readlatch( handle cyhandle, lpword lplatch); writelatch(handle cyhandle, word mask, word latch); getpartnumber(handle cyhandle, lpbyte lpbpartnum); getdeviceproductstring(handle cyhandle, lpvoid lpproduct, lpbyte lpblength, bool bconverttoascii = true ); getdeviceserialnumber(handle cyhandle, lpvoid lpserialnumber, lpbyte lpblength, bool bconverttoascii = true ); getdeviceinterfacestring(handle cyhandle, lpvoid lpinterfacestring, lpbyte lpblength, bool bconverttoascii);
i'm trying import these functions haven't had likle finding right data types:
[dllimportattribute("runtime.dll", entrypoint = "readlatch", callingconvention = callingconvention.cdecl)] static extern int readlatch(handle cyhandle, [marshalas(unmanagedtype. ??????)] ?????? lplatch); [dllimportattribute("runtime.dll", entrypoint = "writelatch", callingconvention = callingconvention.cdecl)] static extern int writelatch(handle cyhandle, word mask, word latch); [dllimportattribute("runtime.dll", entrypoint = "getpartnumber", callingconvention = callingconvention.cdecl)] static extern int getpartnumber(handle cyhandle, lpbyte lpbpartnum); [dllimportattribute("runtime.dll", entrypoint = "getdeviceproductstring", callingconvention = callingconvention.cdecl)] static extern int getdeviceproductstring(handle cyhandle, lpvoid lpproduct, lpbyte lpblength, bool bconverttoascii = true ); [dllimportattribute("runtime.dll", entrypoint = "getdeviceserialnumber", callingconvention = callingconvention.cdecl)] static extern int getdeviceserialnumber(handle cyhandle, lpvoid lpserialnumber, lpbyte lpblength, bool bconverttoascii = true ); [dllimportattribute("runtime.dll", entrypoint = "getdeviceinterfacestring", callingconvention = callingconvention.cdecl)] static extern int getdeviceinterfacestring(handle cyhandle, lpvoid lpinterfacestring, lpbyte lpblength, bool bconverttoascii);
where can find information how represent handle, lpword , others can call functions?
unmanaged types , managed counterparts:
handle
representedintptr
.word
-uint16
for other ones, may need know bit more how used.
hopefully there accompanying documentation api explains parameters do, of them not obvious.
for function, can make assumptions:
readlatch(handle cyhandle, lpword lplatch);
assuming lplatch
"out" parameter (and return type int
):
[dllimportattribute("runtime.dll", entrypoint = "readlatch", callingconvention = callingconvention.cdecl)] static extern int readlatch(intptr cyhandle, out uint16 lplatch);
Comments
Post a Comment