You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've just posted the same question in StackOverflow, but since it concerns your project I wanted to know if you have any solution for this.
My problem: the "friendly name" of the device is always empty. Windows shows a friendly name under "This PC", so it should be feasible.
I have checked similar solutions like this one here based on the same source, but they have the same issue.
This is how your project tries to retrieve the friendly name (from the file WindowsPortableDevice.cs):
var WPD_DEVICE_FRIENDLY_NAME = new PortableDeviceApiLib._tagpropertykey();
WPD_DEVICE_FRIENDLY_NAME.fmtid = new Guid(0x26D4979A, 0xE643, 0x4626, 0x9E, 0x2B, 0x73, 0x6D, 0xC0, 0xC9, 0x2F, 0xDC);
WPD_DEVICE_FRIENDLY_NAME.pid = 12;
string friendlyName;
propertyValues.GetStringValue(ref DevicePropertyKeys.WPD_DEVICE_FRIENDLY_NAME, out friendlyName);
As stated before, the result of friendlyName is always empty.
What I have tried so far:
In this post I found this other possible solution, which uses the PortableDeviceManagerClass instead of the PortableDeviceClass:
string RetrieveFriendlyName(
PortableDeviceApiLib.PortableDeviceManagerClass PortableDeviceManager,
string PnPDeviceID)
{
uint cFriendlyName = 0;
ushort[] usFriendlyName;
string strFriendlyName = String.Empty;
// First, pass NULL as the LPWSTR return string parameter to get the total number
// of characters to allocate for the string value.
PortableDeviceManager.GetDeviceFriendlyName(PnPDeviceID, null, ref cFriendlyName);
// Second allocate the number of characters needed and retrieve the string value.
usFriendlyName = new ushort[cFriendlyName];
if (usFriendlyName.Length > 0)
{
PortableDeviceManager.GetDeviceFriendlyName(PnPDeviceID, usFriendlyName, ref cFriendlyName);
// We need to convert the array of ushorts to a string, one
// character at a time.
foreach (ushort letter in usFriendlyName)
if (letter != 0)
strFriendlyName += (char)letter;
// Return the friendly name
return strFriendlyName;
}
else
return null;
}
The problem here is that I seem to have a different signature of GetDeviceFriendlyName (different Interop.PortableDeviceApiLib.dll?). This is mine:
Yes, I confirm what @xavierpena said. We can change friendly name to model (gabrielepmattia@f0c1b00) or we can add a new field called model and give there the device model.
EDIT: Definitely the second option is better, even for maintaining compatibility gabrielepmattia@ab2bdeb
Hi,
I've just posted the same question in StackOverflow, but since it concerns your project I wanted to know if you have any solution for this.
My problem: the "friendly name" of the device is always empty. Windows shows a friendly name under "This PC", so it should be feasible.
I have checked similar solutions like this one here based on the same source, but they have the same issue.
This is how your project tries to retrieve the friendly name (from the file WindowsPortableDevice.cs):
As stated before, the result of
friendlyName
is always empty.What I have tried so far:
In this post I found this other possible solution, which uses the
PortableDeviceManagerClass
instead of thePortableDeviceClass
:The problem here is that I seem to have a different signature of
GetDeviceFriendlyName
(differentInterop.PortableDeviceApiLib.dll
?). This is mine:It does not accept
null
orushort[]
.I tested the following, just to see how it behaved:
...but it threw an exception:
"The data is invalid. (Exception from HRESULT: 0x8007000D)"
.The text was updated successfully, but these errors were encountered: