G
Guest
I'm an absolute newb to P/Invoke, and got stuck on this little thing, what would be the correct P/Invoke syntax to import the following dll function
NTSTATUS TdiRegisterProvider
IN PUNICODE_STRING ProviderName
OUT HANDLE *ProviderHandle )
definition of the data types used are
typedef LONG NTSTATUS, *PNTSTATUS
typedef struct _UNICODE_STRING
USHORT Length
USHORT MaximumLength
PWSTR Buffer
} UNICODE_STRING, *PUNICODE_STRING
this is my code for the dllimport, which is not workin
[StructLayout( LayoutKind.Sequential, CharSet = CharSet.Unicode )
public class UnicodeStrin
public ushort Length
public ushort MaximumLength
public string Buffer
[DllImport( "drivers\\tdi.sys", EntryPoint="TdiRegisterProvider" )
public static extern int TdiRegisterProvider(UnicodeString name, ref IntPtr handle)
also trie
[DllImport( "drivers\\tdi.sys", EntryPoint="TdiRegisterProvider" )
public static extern int TdiRegisterProvider(UnicodeString name, [Out] IntPtr handle)
don't laugh if it looks completely ridiculous, I'd appretiate it if someone will point out to me what I'm doing wrong
also, on a side note, can someone tell me when to define an unmanaged struct as managed class and when to define it as managed struct. what are the implications of the two methods? thanks
NTSTATUS TdiRegisterProvider
IN PUNICODE_STRING ProviderName
OUT HANDLE *ProviderHandle )
definition of the data types used are
typedef LONG NTSTATUS, *PNTSTATUS
typedef struct _UNICODE_STRING
USHORT Length
USHORT MaximumLength
PWSTR Buffer
} UNICODE_STRING, *PUNICODE_STRING
this is my code for the dllimport, which is not workin
[StructLayout( LayoutKind.Sequential, CharSet = CharSet.Unicode )
public class UnicodeStrin
public ushort Length
public ushort MaximumLength
public string Buffer
[DllImport( "drivers\\tdi.sys", EntryPoint="TdiRegisterProvider" )
public static extern int TdiRegisterProvider(UnicodeString name, ref IntPtr handle)
also trie
[DllImport( "drivers\\tdi.sys", EntryPoint="TdiRegisterProvider" )
public static extern int TdiRegisterProvider(UnicodeString name, [Out] IntPtr handle)
don't laugh if it looks completely ridiculous, I'd appretiate it if someone will point out to me what I'm doing wrong
also, on a side note, can someone tell me when to define an unmanaged struct as managed class and when to define it as managed struct. what are the implications of the two methods? thanks