Interop question

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?
 
M

Mattias Sjögren

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top