473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Marshalling Data Question

I am trying to obtain a list of HID devices and am trying to use UINT
GetRawInputDeviceList( PRAWINPUTDEVICELIST pRawInputDeviceList,
PUINT puiNumDevices, UINT cbSize);
a USER32.dll. but the function fails. Here is the code. I am new to
Marshalling. Can anyone suggest my error and why? I am using C# with Visual
Studio 2003 with 1.1 .NET
Code:
/*typedef struct tagRAWINPUTDEVICELIST {
HANDLE hDevice;
DWORD dwType;
} RAWINPUTDEVICELIST, *PRAWINPUTDEVICELIST;
*/
converts to :
[ StructLayout( LayoutKind.Sequential )]
public class RAWINPUTDEVICELIST
{
public IntPtr Device;
public int Type;
}
and
RAWINPUTDEVICELIST pRawInputDeviceList;

/*UINT GetRawInputDeviceList( PRAWINPUTDEVICELIST
pRawInputDeviceList,
PUINT puiNumDevices, UINT cbSize);*/
converts to:
[ DllImport( "C:Windows\\System32\\USER32.DLL" )]
public static extern uint GetRawInputDeviceList( [In, Out]
RAWINPUTDEVICELIST pRawInputDeviceList,[In, Out] uint NumDevices,uint size );

and the call:
uint bb = GetRawInputDeviceList( pRawInputDeviceList, NumDevices, size );
fails and I get the following error:
Unable to load DLL (C:Windows\System32\USER32.DLL).
any suggestions??

--
BP
Jun 1 '06 #1
5 2870
> [ DllImport( "C:Windows\\System32\\USER32.DLL" )]
^^^^

That's not a valid path, you would need a backslash after the colon.
But it's better to remove the path and just specify the file name,
User32.dll.

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

^^^^^^^^^^^^^^^^^^^^^^^^^

NumDevices should be a ref parameter.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jun 1 '06 #2
Thanks, but I am still having difficulty. Here are the changes made:
[ 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.SizeO f(pRawInputDeviceList);
uint bb = GetRawInputDeviceList( pRawInputDeviceList,ref
NumDevices,size);

This builds ok but I get the following error:
Additional information: Unable to find an entry point named
GetRawInputDeviceList in DLL USER32.DLL. Any thoughts??
--
BP
"Mattias Sjögren" wrote:
[ DllImport( "C:Windows\\System32\\USER32.DLL" )]

^^^^

That's not a valid path, you would need a backslash after the colon.
But it's better to remove the path and just specify the file name,
User32.dll.

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

^^^^^^^^^^^^^^^^^^^^^^^^^

NumDevices should be a ref parameter.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Jun 2 '06 #3
This builds ok but I get the following error:
Additional information: Unable to find an entry point named
GetRawInputDeviceList in DLL USER32.DLL. Any thoughts??


Wrong operating system perhaps? GetRawInputDeviceList is implemented
on Windows XP and later.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jun 2 '06 #4
Gee, your sharp! I did not catch that fact. (Windows 2000). Thanks for your
help!
--
BP
"PickwickBob3" wrote:
I am trying to obtain a list of HID devices and am trying to use UINT
GetRawInputDeviceList( PRAWINPUTDEVICELIST pRawInputDeviceList,
PUINT puiNumDevices, UINT cbSize);
a USER32.dll. but the function fails. Here is the code. I am new to
Marshalling. Can anyone suggest my error and why? I am using C# with Visual
Studio 2003 with 1.1 .NET
Code:
/*typedef struct tagRAWINPUTDEVICELIST {
HANDLE hDevice;
DWORD dwType;
} RAWINPUTDEVICELIST, *PRAWINPUTDEVICELIST;
*/
converts to :
[ StructLayout( LayoutKind.Sequential )]
public class RAWINPUTDEVICELIST
{
public IntPtr Device;
public int Type;
}
and
RAWINPUTDEVICELIST pRawInputDeviceList;

/*UINT GetRawInputDeviceList( PRAWINPUTDEVICELIST
pRawInputDeviceList,
PUINT puiNumDevices, UINT cbSize);*/
converts to:
[ DllImport( "C:Windows\\System32\\USER32.DLL" )]
public static extern uint GetRawInputDeviceList( [In, Out]
RAWINPUTDEVICELIST pRawInputDeviceList,[In, Out] uint NumDevices,uint size );

and the call:
uint bb = GetRawInputDeviceList( pRawInputDeviceList, NumDevices, size );
fails and I get the following error:
Unable to load DLL (C:Windows\System32\USER32.DLL).
any suggestions??

--
BP

Jun 4 '06 #5
I have a question about how to marshal the PRAWINPUTDEVICELIST
pRawInputDeviceList which is --- >[out] Pointer to buffer that holds an array
of RAWINPUTDEVICELIST structures for the devices attached to the system.
The steps I have followed is to call GetRawInputDeviceList() with
pRawInputDeviceList = null to get the NumDevices. Then create the array
myArray = new RAWINPUTDEVICELIST[NumDevices];

At this point I am unsure as to how to marshal the pRawInputDeviceList above
which is a pointer to the buffer for the method -> GetRawInputDeviceList(
pRawInputDeviceList, NumDevices, size ) . Can you help?

BP
"PickwickBob3" wrote:
Gee, your sharp! I did not catch that fact. (Windows 2000). Thanks for your
help!
--
BP
"PickwickBob3" wrote:
I am trying to obtain a list of HID devices and am trying to use UINT
GetRawInputDeviceList( PRAWINPUTDEVICELIST pRawInputDeviceList,
PUINT puiNumDevices, UINT cbSize);
a USER32.dll. but the function fails. Here is the code. I am new to
Marshalling. Can anyone suggest my error and why? I am using C# with Visual
Studio 2003 with 1.1 .NET
Code:
/*typedef struct tagRAWINPUTDEVICELIST {
HANDLE hDevice;
DWORD dwType;
} RAWINPUTDEVICELIST, *PRAWINPUTDEVICELIST;
*/
converts to :
[ StructLayout( LayoutKind.Sequential )]
public class RAWINPUTDEVICELIST
{
public IntPtr Device;
public int Type;
}
and
RAWINPUTDEVICELIST pRawInputDeviceList;

/*UINT GetRawInputDeviceList( PRAWINPUTDEVICELIST
pRawInputDeviceList,
PUINT puiNumDevices, UINT cbSize);*/
converts to:
[ DllImport( "C:Windows\\System32\\USER32.DLL" )]
public static extern uint GetRawInputDeviceList( [In, Out]
RAWINPUTDEVICELIST pRawInputDeviceList,[In, Out] uint NumDevices,uint size );

and the call:
uint bb = GetRawInputDeviceList( pRawInputDeviceList, NumDevices, size );
fails and I get the following error:
Unable to load DLL (C:Windows\System32\USER32.DLL).
any suggestions??

--
BP

Jun 13 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: PHil Coveney | last post by:
Hello, I am having difficulty marshalling structures when calling DeviceIoControl. I am importing this Win32 function as static extern int DeviceIoControl (int hDevice, int...
4
by: Animesh | last post by:
Hi All, I don't know whethher this is possible or not. This is the result of a bad design problem. Here I go; I have a structure like this: typedef struct _s_index_entry { char *doc_id;...
1
by: MuZZy | last post by:
Hello, I am probably facing a sort of language barrier, but i can't really get what 'marshalling' is in terms of .NET Is it a kind of type casting? And when do you use it? Thank you, Andrey
2
by: Rookie | last post by:
Hi, I had a question on DllImport. On importing a function from a VC++ dll using DllImport (to a C# program), the function argument data types and the return types may be of a type that is not...
10
by: Bryce Calhoun | last post by:
Hello, First of all, this is a .NET 1.1 component I'm creating. SUMMARY ----------------------- This component that I'm creating is, for all intents and purposes, a document parser (I'm...
2
by: calenlas | last post by:
Hi all, I'm taking my first steps into C# <--C++ DLL Interop and unfortunately I've run into (what seems to be) a very complicated case as my first task. Perhaps someone here can help me. I...
2
by: d-42 | last post by:
Hi, I'm pretty sure I've just got a Marshalling problem, but I'm completely stumped. If there is a better newsgroup to post this in, please point me towards it. First I'm trying to use...
1
by: d-42 | last post by:
Hi, I'm pretty sure I've just got a Marshalling problem, but I'm completely stumped. If there is a better newsgroup to post this in, please point me towards it. First I'm trying to use...
1
by: roche72 | last post by:
I am having some trouble marshalling data between c++/C# Here is the C++ code: --------------------------------------------------------------------------------- typedef struct { ...... ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.