Interop question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

[ StructLayout( LayoutKind.Sequential )]
public class RAWINPUTDEVICELIST
{
public IntPtr Device;
public int Type;
}

[ DllImport( "user32.DLL",EntryPoint="GetRawInputDeviceList" )]

public static extern uint GetRawInputDeviceList([In, Out] RAWINPUTDEVICELIST
pRawInputDeviceList, ref uint NumDevices,uint size );

RAWINPUTDEVICELIST pRawInputDeviceList = new RAWINPUTDEVICELIST();

size =
(uint)System.Runtime.InteropServices.Marshal.SizeOf(pRawInputDeviceList);

uint bb = GetRawInputDeviceList( null,ref NumDevices,size); // this returns
4 for NumDevices which is correct.

bb = GetRawInputDeviceList(pRawInputDeviceList,ref NumDevices,size);

What I can not figure out is how to set up the pRawInputDeviceList as a
pointer to a buffer that holds and array of RAWINPUTDEVICELIST structures.
Can you help? If I call the fuction as written I get just one of the
RawInputDevices not the array?
 
What I can not figure out is how to set up the pRawInputDeviceList as a
pointer to a buffer that holds and array of RAWINPUTDEVICELIST structures.
Can you help?

Change RAWINPUTDEVICELIST to a struct. Change the parameter type to
RAWINPUTDEVICELIST[].


Mattias
 
Thanks for your help. --
BP


Mattias Sjögren said:
What I can not figure out is how to set up the pRawInputDeviceList as a
pointer to a buffer that holds and array of RAWINPUTDEVICELIST structures.
Can you help?

Change RAWINPUTDEVICELIST to a struct. Change the parameter type to
RAWINPUTDEVICELIST[].


Mattias
 
Back
Top