Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
this is my C structure which i want to pinvoke

typedef struct _SCANNER_NOTIFICATION {
	
	ULONG ProcessId;
	USHORT FileNameLength;	//string length
	WCHAR FileName[1];	//Variable length string

} SCANNER_NOTIFICATION


What I have tried:

[StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
       public struct SCANNER_NOTIFICATION
       {

           /// ULONG->int
           public int ProcessId;

           /// USHORT->short
           public short FileNameLength;

           /// WCHAR[1]
           public IntPtr FileName;
       }
Posted
Updated 5-May-20 4:57am
Comments
KarstenK 5-May-20 10:55am    
in my experience is it easier to try with WCHAR FileName[0x100];

1 solution

You cannot P/Invoke a structure. You P/Invoke a library method to add content to, or remove content from, the structure. So you need to provide the information about which library you are trying to use with this structure.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900