How to extract a device or driver's name?

Yes.

Randal Erman wrote: v:* {behavior:url(#default#VML);} o:* {behavior:url(#default#VML);} w:* {behavior:url(#default#VML);} .shape {behavior:url(#default#VML);} Do you mean the name that is associated with the device in the INF?

---------------------------------

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Thursday, March 30, 2006 11:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I mean the name of the USB device shown in device manager.

Peter Wieland wrote:
what do you mean by device name?

-p

---------------------------------

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Wednesday, March 29, 2006 2:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to extract a device or driver’s name?
Hi All,

I am trying to extract a name of the device or the driver from

typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A {
DWORD cbSize;
CHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA_A

defined in DDK.

Can somebody please tell me how to extract the name as this structure doesn’t have the name field. It gives the DevicePath but not device name.

Thanks,

Harsha

---------------------------------

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------

Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

Hi,

Thank you. I used first SPDRP_FRIENDLYNAME property & then SPDRP_DEVICEDESC but both of them didn’t extract any data.

Any suggestions? These are the parameters:

DWORD *dwRegType;

SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
dwRegType,
(BYTE*) szFriendlyName,
2096,
NULL);

Thanks,
Harsha

Doron Holan wrote:
SetupDiGetDeviceRegistryProperty with a property of SPDRP_FRIENDLYNAME. If that fails, use the SPDRP_DEVICEDESC property.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Thursday, March 30, 2006 11:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I mean the name of the USB device shown in device manager.

Peter Wieland
wrote:
what do you mean by device name?

-p


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Wednesday, March 29, 2006 2:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to extract a device or driver’s name?
Hi All,

I am trying to extract a name of the device or the driver from
typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A {
DWORD cbSize;
CHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA_A

defined in DDK.

Can somebody please tell me how to extract the name as this structure doesn’t have the name field. It gives the DevicePath but not device name.

Thanks,
Harsha

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.

what did you get? Error? zero data?

-p


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 10:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Hi,

Thank you. I used first SPDRP_FRIENDLYNAME property & then SPDRP_DEVICEDESC but both of them didn’t extract any data.

Any suggestions? These are the parameters:

DWORD *dwRegType;

SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
dwRegType,
(BYTE*) szFriendlyName,
2096,
NULL);

Thanks,
Harsha

Doron Holan wrote:

SetupDiGetDeviceRegistryProperty with a property of SPDRP_FRIENDLYNAME. If that fails, use the SPDRP_DEVICEDESC property.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Thursday, March 30, 2006 11:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I mean the name of the USB device shown in device manager.

Peter Wieland wrote:
what do you mean by device name?

-p


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Wednesday, March 29, 2006 2:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to extract a device or driver’s name?
Hi All,

I am trying to extract a name of the device or the driver from
typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A {
DWORD cbSize;
CHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA_A

defined in DDK.

Can somebody please tell me how to extract the name as this structure doesn’t have the name field. It gives the DevicePath but not device name.

Thanks,
Harsha

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

________________________________

New Yahoo! Messenger with Voice. Call regular phones from your PC http: and save big. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer</http:>

I just got nothing. I am trying to extract this data in MFC app in a combo box, but combo box is empty.

Thanks,
Harsha

Peter Wieland wrote:
what did you get? Error? zero data?

-p

---------------------------------
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 10:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Hi,

Thank you. I used first SPDRP_FRIENDLYNAME property & then SPDRP_DEVICEDESC but both of them didn’t extract any data.

Any suggestions? These are the parameters:

DWORD dwRegType;

SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
dwRegType,
(BYTE
) szFriendlyName,
2096,
NULL);

Thanks,
Harsha

Doron Holan wrote:
SetupDiGetDeviceRegistryProperty with a property of SPDRP_FRIENDLYNAME. If that fails, use the SPDRP_DEVICEDESC property.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Thursday, March 30, 2006 11:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I mean the name of the USB device shown in device manager.

Peter Wieland
wrote:
what do you mean by device name?

-p


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Wednesday, March 29, 2006 2:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to extract a device or driver’s name?
Hi All,

I am trying to extract a name of the device or the driver from
typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A {
DWORD cbSize;
CHAR DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA_A

defined in DDK.

Can somebody please tell me how to extract the name as this structure doesn’t have the name field. It gives the DevicePath but not device name.

Thanks,
Harsha

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC and save big. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min.

What did SetupDiGetDeviceRegistryProperty return? TRUE or FALSE?


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 10:58 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I just got nothing. I am trying to extract this data in MFC app in a combo box, but combo box is empty.
?
Thanks,
Harsha

Peter Wieland wrote:
what did you get?? Error?? zero data?
?
-p


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 10:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?
Hi,
?
Thank you. I used first SPDRP_FRIENDLYNAME property & then SPDRP_DEVICEDESC but both of them didn’t extract any data.
?
Any suggestions? These are?the parameters:
?
DWORD dwRegType;
?
SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
??? &pHeader->pInfo[i].DeviceInfoData,
???SPDRP_DEVICEDESC,
??? dwRegType,
???(BYTE
) szFriendlyName,
??? 2096,
??? NULL);
?
Thanks,
Harsha

Doron Holan wrote:
SetupDiGetDeviceRegistryProperty with a property of SPDRP_FRIENDLYNAME. If that fails, use the SPDRP_DEVICEDESC property.

d


From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Thursday, March 30, 2006 11:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I mean the name of the USB device shown in device manager.

Peter Wieland wrote:
what do you mean by device name?
?
-p

_
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Wednesday, March 29, 2006 2:39 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to extract a device or driver’s name?
Hi All,
?
I am trying to extract a name of the device or the driver from
typedef struct SP_DEVICE_INTERFACE_DETAIL_DATA_A {
??? DWORD? cbSize;
??? CHAR?? DevicePath[ANYSIZE_ARRAY];
} SP_DEVICE_INTERFACE_DETAIL_DATA_A
?
defined in DDK.
?
Can somebody please tell me how to extract the name as this structure doesn’t have the name field. It gives the DevicePath but not device name.
?
Thanks,
Harsha

Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

________________________________________
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1?/min. — Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256 To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

“I just got nothing” is user talk. Talk like a programmer. Run your app in
a debugger, set a breakpoint after the call to
SetupDiGetDeviceRegistryProperty. Then examine the variables that were
returned to you, the return value of SetupDiGetDeviceRegistryProperty, and
if the return value is FALSE, then also evaluate GetLastError(). If these
values don’t show you what the problem is, then post the values to the list,
and we will try to help you.

Judging from the code you have posted, you are not checking the return value
of the function. You must do this. If the function returns FALSE, then it
has failed, and the contents of the return buffer (szFriendlyName) are
undefined. (The buffer may have been overwritten, or it may not, or it may
contain “GREEN CHEESE” over and over.) If you are not checking the return
value, you are simply not programming, only stumbling in the dark. If you
are checking the return value, and it is FALSE, then what is the value of
GetLastError()?

Also note that you’ve committed a very basic programming error. You are
passing an uninitialized pointer to SetupDiGetDeviceRegistryProperty,
specifically dwRegType. dwRegType needs to be a local variable of type
DWORD, NOT “DWORD*”. “DWORD*” is a pointer to a DWORD, but you have not
initialized the pointer. When your code calls
SetupDiGetDeviceRegistryProperty, it will pass stack noise as the pointer to
the registry type, and SetupDiGetDeviceRegistryProperty will then store the
registry type of the property in a random pointer. This will cause
mysterious errors and crashes that are difficult to predict or discover.
Instead, declare the variable as “DWORD dwRegType;” and pass “&dwRegType” to
SetupDiGetDeviceRegistryProperty. This is a basic C issue.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 1:58 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I just got nothing. I am trying to extract this data in MFC app in a combo
box, but combo box is empty.

Thanks,
Harsha

Peter Wieland wrote:

what did you get? Error? zero data?

-p

________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 10:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Hi,

Thank you. I used first SPDRP_FRIENDLYNAME property & then
SPDRP_DEVICEDESC but both of them didn’t extract any data.

Any suggestions? These are the parameters:

DWORD dwRegType;

SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
dwRegType,
(BYTE
) szFriendlyName,
2096,
NULL);

Thanks,
Harsha

Thanks Arlie for your detailed email.

Here is my code:

BOOL Value;

for(i=0;inInfo;i++)
{

memset(szFriendlyName, 0, 2096);

Value = SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
&dwRegType,
(PBYTE)szFriendlyName,
2096,
NULL);

if(Value)
{
CString s((PBYTE)szFriendlyName);
combo1.AddString(s);
edit = “TRUE”;
}
else
if(Value == FALSE)
{
Err1 = GetLastError();
edit = Err1; //This is the edit box I have created to display the error value.
}

But unfortunately I don’t see any value in the edit box. I don’t know the reason.

Thank you.
Harsha

Arlie Davis wrote:
“I just got nothing” is user talk. Talk like a programmer. Run your app in
a debugger, set a breakpoint after the call to
SetupDiGetDeviceRegistryProperty. Then examine the variables that were
returned to you, the return value of SetupDiGetDeviceRegistryProperty, and
if the return value is FALSE, then also evaluate GetLastError(). If these
values don’t show you what the problem is, then post the values to the list,
and we will try to help you.

Judging from the code you have posted, you are not checking the return value
of the function. You must do this. If the function returns FALSE, then it
has failed, and the contents of the return buffer (szFriendlyName) are
undefined. (The buffer may have been overwritten, or it may not, or it may
contain “GREEN CHEESE” over and over.) If you are not checking the return
value, you are simply not programming, only stumbling in the dark. If you
are checking the return value, and it is FALSE, then what is the value of
GetLastError()?

Also note that you’ve committed a very basic programming error. You are
passing an uninitialized pointer to SetupDiGetDeviceRegistryProperty,
specifically dwRegType. dwRegType needs to be a local variable of type
DWORD, NOT “DWORD*”. “DWORD*” is a pointer to a DWORD, but you have not
initialized the pointer. When your code calls
SetupDiGetDeviceRegistryProperty, it will pass stack noise as the pointer to
the registry type, and SetupDiGetDeviceRegistryProperty will then store the
registry type of the property in a random pointer. This will cause
mysterious errors and crashes that are difficult to predict or discover.
Instead, declare the variable as “DWORD dwRegType;” and pass “&dwRegType” to
SetupDiGetDeviceRegistryProperty. This is a basic C issue.

– arlie



From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 1:58 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

I just got nothing. I am trying to extract this data in MFC app in a combo
box, but combo box is empty.

Thanks,
Harsha

Peter Wieland
wrote:

what did you get? Error? zero data?

-p



From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 10:13 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Hi,

Thank you. I used first SPDRP_FRIENDLYNAME property & then
SPDRP_DEVICEDESC but both of them didn’t extract any data.

Any suggestions? These are the parameters:

DWORD dwRegType;

SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
dwRegType,
(BYTE
) szFriendlyName,
2096,
NULL);

Thanks,
Harsha


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
New Yahoo! Messenger with Voice. Call regular phones from your PC for low, low rates.

You didn’t take my advice or Doron’s. Stop looking at the edit box – it is
clearly not giving you any useful information. Look at the code, and use a
debugger. Step through the code with a debugger, and examine the values of
the variables.

The code you have posted is incomplete. You *still* haven’t said whether
SetupDiGetDeviceRegistryProperty returns TRUE or FALSE. You also have not
specified what the value of dwRegType is on return.

You may not be handling ANSI/UNICODE translation correctly. Are you
compiling with #define UNICODE / #define _UNICODE? What is the type of
szFriendlyName? If it is TCHAR, or CHAR, or WCHAR, or whatever, you’re
coercing its type in the call to the CString constructor. If you are
compiling with #define UNICODE / _UNICODE, then SetupDi* is returning a
Unicode string into szFriendlyName, and the wrong CString constructor is
being called, and Unicode characters are incorrectly being interpreted as
ANSI.

We can only help you so much – at a certain level, you have to do the work.
This is basic C programming, not rocket science.

– arlie


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 3:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Thanks Arlie for your detailed email.

Here is my code:

BOOL Value;

for(i=0;inInfo;i++)
{

memset(szFriendlyName, 0, 2096);

Value = SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
&dwRegType,
(PBYTE)szFriendlyName,
2096,
NULL);

if(Value)
{
CString s((PBYTE)szFriendlyName);
combo1.AddString(s);
edit = “TRUE”;
}
else
if(Value == FALSE)
{
Err1 = GetLastError();
edit = Err1; //This is the edit box I have created to display
the error value.
}

But unfortunately I don’t see any value in the edit box. I don’t know the
reason.

Thank you.
Harsha

Thanks Arlie. I will take a look at all the points you have mentioned & reply you.

Sorry for my lack of knowledge.

Thanks,
Harsha

Arlie Davis wrote:
You didn’t take my advice or Doron’s. Stop looking at the edit box – it is
clearly not giving you any useful information. Look at the code, and use a
debugger. Step through the code with a debugger, and examine the values of
the variables.

The code you have posted is incomplete. You still haven’t said whether
SetupDiGetDeviceRegistryProperty returns TRUE or FALSE. You also have not
specified what the value of dwRegType is on return.

You may not be handling ANSI/UNICODE translation correctly. Are you
compiling with #define UNICODE / #define _UNICODE? What is the type of
szFriendlyName? If it is TCHAR, or CHAR, or WCHAR, or whatever, you’re
coercing its type in the call to the CString constructor. If you are
compiling with #define UNICODE / _UNICODE, then SetupDi* is returning a
Unicode string into szFriendlyName, and the wrong CString constructor is
being called, and Unicode characters are incorrectly being interpreted as
ANSI.

We can only help you so much – at a certain level, you have to do the work.
This is basic C programming, not rocket science.

– arlie

________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 3:06 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Thanks Arlie for your detailed email.

Here is my code:

BOOL Value;

for(i=0;i
nInfo;i++)
{

memset(szFriendlyName, 0, 2096);

Value = SetupDiGetDeviceRegistryProperty(pHeader->hDevInfo,
&pHeader->pInfo[i].DeviceInfoData,
SPDRP_DEVICEDESC,
&dwRegType,
(PBYTE)szFriendlyName,
2096,
NULL);

if(Value)
{
CString s((PBYTE)szFriendlyName);
combo1.AddString(s);
edit = “TRUE”;
}
else
if(Value == FALSE)
{
Err1 = GetLastError();
edit = Err1; //This is the edit box I have created to display
the error value.
}

But unfortunately I don’t see any value in the edit box. I don’t know the
reason.

Thank you.
Harsha


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2¢/min or less.

It’s not the lack of knowledge, but of effort. Just investigate the problem
further first, with the tools in front of you, and you’ll probably find the
problem.


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 3:42 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Thanks Arlie. I will take a look at all the points you have mentioned &
reply you.

Sorry for my lack of knowledge.

Thanks,
Harsha

Hi Arlie,

Thank you so much for your guidance. I am able to extract the name. I commented out the following sentence & it worked.

memset(szFriendlyName, 0, 2096);

But before that I made sure that the Value was TRUE using the debugger.

But I wanted to know one thing. I am not sure whether I am compiling with #define UNICODE/ _UNICODE. How to find that out? Also if that is the case how to convert from char to string?

In this case I used char szFriendlyName.

Thank you again for your help.

Harsha

Arlie Davis wrote:
It’s not the lack of knowledge, but of effort. Just investigate the problem
further first, with the tools in front of you, and you’ll probably find the
problem.

________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 3:42 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Thanks Arlie. I will take a look at all the points you have mentioned &
reply you.

Sorry for my lack of knowledge.

Thanks,
Harsha


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

---------------------------------
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

I would suggest you try reading some documentation about the compiler. MSDN Library contains a lot of what you need. Define ‘string’ and how it differs from char.
“Harsha Inamdar” wrote in message news:xxxxx@ntdev…
Hi Arlie,

Thank you so much for your guidance. I am able to extract the name. I commented out the following sentence & it worked.

memset(szFriendlyName, 0, 2096);

But before that I made sure that the Value was TRUE using the debugger.

But I wanted to know one thing. I am not sure whether I am compiling with #define UNICODE/ _UNICODE. How to find that out? Also if that is the case how to convert from char to string?

In this case I used char szFriendlyName.

Thank you again for your help.

Harsha

Arlie Davis wrote:
It’s not the lack of knowledge, but of effort. Just investigate the problem
further first, with the tools in front of you, and you’ll probably find the
problem.

________________________________

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Harsha Inamdar
Sent: Friday, March 31, 2006 3:42 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] How to extract a device or driver’s name?

Thanks Arlie. I will take a look at all the points you have mentioned &
reply you.

Sorry for my lack of knowledge.

Thanks,
Harsha


Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

------------------------------------------------------------------------------
How low will we go? Check out Yahoo! Messenger’s low PC-to-Phone call rates.

As for me, I don’t like SetupDI* interface and in the same situation
prefer looking for appropriate data in the registry directly.

All data which SetupDI* may give you are in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum.…

Regards,
Michael.

Programming is hard. Plain and simple. Some problems are simple, some
are hard. Some APIs you like, some you don’t. Going behind the back of
those APIs and getting at the data yourself will only cause problems for
you and your customers.

Yes, right now device data is stored under the Enum key. That doesn’t
mean it will be there in the future (very likely it won’t be). Right
now you have access to the Enum key today doesn’t mean you will have
access to it tomorrow (very likely it will be restricted down much
tighter). Right now your code works b/c you are running as an admin,
the APIs can provide read access for lower rights users.

To get at device specific data, you need the instance path. The only
generic way I know of getting that path is through setupdi. You can
hard code values all you want, but that is not portable across machines.

In the end, just use the API provided for you. It protects you from
future changes and are a supported scenario. Spelunking the registry
directly is not.

d

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Grabelkovsky,
Michael
Sent: Saturday, April 01, 2006 11:33 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to extract a device or driver’s name?

As for me, I don’t like SetupDI* interface and in the same situation
prefer looking for appropriate data in the registry directly.

All data which SetupDI* may give you are in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum.…

Regards,
Michael.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

That will work until the PNP team decides that they want to change the
structure of the registry (it’s undocumented, so they can do that) or
decide they don’t want to keep the data in the registry anymore. At
that point your app will stop working.

I agree the SetupDI interface could be better. But it is the right way
to get this sort of information.

-p

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Grabelkovsky,
Michael
Sent: Saturday, April 01, 2006 11:33 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to extract a device or driver’s name?

As for me, I don’t like SetupDI* interface and in the same situation
prefer looking for appropriate data in the registry directly.

All data which SetupDI* may give you are in:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum.…

Regards,
Michael.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

Doron, Peter!

I’d like agree about SetupDi* advantages. But some events and privet
experience have pushed me analyze registry.
I name only the mains:

  1. About year ago I tried to use Protocol NDIS example from
    Microsoft DDK. It is loading and even working about. But!!! Computer
    hangs up on the reboot, if the driver remains in the memory. The reason
    was the attempt the Protocol driver reconfiguration via SetupDI*. I
    receive the stable allergy to SetupDI* after.
  2. I right now have finishing the huge code which analyzes a lot of
    Registry sections comprising Hardware installation info. Code has been
    checked for every Windows version from W2000 to W2K3. It works perfect
    and (the most important!) has NOT any branch, dependently from OS
    version. Obviously, it is not guarantee from future problems. But who
    from us has these guarantees…? :slight_smile:
  3. Unfortunately SetupDi* doesn’t deliver all useful information
    which I need. As example only, it has NOT callback about hardware
    configuration changes.
  4. I myself one time had been forced edit registry after hardware
    installation due it was the single way to close the SetupDI* problem.

I agree with you, I would prefer using official documented API. But if
this API would be defined and written better, than SetupDI* done…

Regards,
Michael.

Doron Holan wrote:

Programming is hard. Plain and simple. Some problems are simple, some
are hard. Some APIs you like, some you don’t. Going behind the back of
those APIs and getting at the data yourself will only cause problems for
you and your customers.

That’s true. However, I have to say that the SetupDi APIs are among the
most arcane and obscure APIs in the entire Win32 set. Despite the fact
that I have written several, I seriously doubt that I could successfully
create a SetupDi-based program from scratch with the MSDN docs, without
being able to cut-and-paste working code from a sample.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> ----------

From: xxxxx@lists.osr.com[SMTP:xxxxx@lists.osr.com] on behalf of Tim Roberts[SMTP:xxxxx@probo.com]
Reply To: Windows System Software Devs Interest List
Sent: Monday, April 03, 2006 8:40 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] How to extract a device or driver’s name?

That’s true. However, I have to say that the SetupDi APIs are among the
most arcane and obscure APIs in the entire Win32 set.

I guess the word ‘obnoxious’ is the most accurate here :slight_smile:

Despite the fact that I have written several, I seriously doubt that I could successfully
create a SetupDi-based program from scratch with the MSDN docs, without
being able to cut-and-paste working code from a sample.

It is possible and necessary for non-trivial cases which can’t be find in the samples. Time consuming and unnecessarily hard. Docs should contain the relations between APIs, ideally as a graph. I wonder if there is any person in the world, including Setup API inventors, who fully understands it and who’d be able to describe all relations. If it is even possible. Sometimes it is better to throw out the monster and design new one from scratch.

Best regards,

Michal Vodicka
UPEK, Inc.
[xxxxx@upek.com, http://www.upek.com]

Correct. DevicePath is the one which can be passed to CreateFile. In fact,
the only purpose of the “device interface detail” entity is to provide you with
the openable filename.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Harsha Inamdar”
To: “Windows System Software Devs Interest List”
Sent: Thursday, March 30, 2006 2:38 AM
Subject: [ntdev] How to extract a device or driver’s name?

> Hi All,
>
> I am trying to extract a name of the device or the driver from
> typedef struct _SP_DEVICE_INTERFACE_DETAIL_DATA_A {
> DWORD cbSize;
> CHAR DevicePath[ANYSIZE_ARRAY];
> } SP_DEVICE_INTERFACE_DETAIL_DATA_A
>
> defined in DDK.
>
> Can somebody please tell me how to extract the name as this structure
doesn’t have the name field. It gives the DevicePath but not device name.
>
> Thanks,
> Harsha
>
>
> ---------------------------------
> Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.
> —
> Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> That’s true. However, I have to say that the SetupDi APIs are among the

most arcane and obscure APIs in the entire Win32 set. Despite the fact

Some of the PnP IDs (I think Instance ID) are just not available via SetupDi.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com