Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
In C++ there is a function called SetupDiGetDeviceRegistryProperty, that retrieves the device property. But in C# I can not find this function. Could anybody help me to tell me what it is called in C# ?
Posted
I think that you must use P/Invoke...

 

In C++ I can use this function to get the device properties. Frankly I am interested in getting the friendly name of the device (fname), so I know exactly which com ports exist.

 

bool bSuccess = SetupDiGetDeviceRegistryProperty(hDevInfo, &devdata, SPDRP_FRIENDLYNAME, NULL, (PBYTE)fname, sizeof(fname), NULL);

 

But I can not find anything that just look alike in C#. Any suggestion ?.

Posted
You might be able to retrieve the device information through the WMI support in .NET, but I don't know how this works.

 

It looks like this http://www.thecodeproject.com/csharp/DivingSysProg3.asp does something close to what you want, you might want to check it out (they dont use WMI but use the win32api directly)

 

Thanks alot Wile, just what I need.

 

I just need to Import the setupapi dll to use the SetupDiGetDeviceRegistryProperty function. I just can not get why nothing alike exist in C#. If anybody reads this, and know how to do it in C# way, please let me know.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...