Click here to Skip to main content
16,005,038 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

Please give me the C# equivalent of below code. GetAvailableDevices() method is using the out param pointer to struct.

C++
typedef unsigned long deviceid;
struct DeviceList 
{
	DWORD count;
	DWORD padding;
	struct DeviceInfo *DeviceInfo;
};
struct DeviceInfo 
{
	deviceid DevID;
	DWORD Status;
	const char * Description;
	const char * LongDescription;
};
ERRORID WINAPI GetAvailableDevices(struct DeviceList **DeviceList);
Posted
Updated 14-May-10 6:09am
v4

I am not familiar with GetAvailableDevices() but a quick Google found this[^] on stackoverflow.

Any help?
 
Share this answer
 
v2
You can use the PtrToStructure method in the Marshal class. Alternatively you can use the Copy method to construct the struct instances from a byte[].

It looks like you'll have to do some pointer aritmetic to increment the pointer DeviceList.count -1 number of times to get each device's info.

Without knowing what API this is part of so we have all the reference material it is hard to help any further.
 
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