Ref: "Ap1400ProgGuide1_2.docx"
Page 34 of 42
Document Revision: “1.2”
Document Date: “9 Apr. 2013”
GetName
Gets the enumerated name of an enumerated device
Prototype
LPSTR
WINAPI GetName(
int
iIndex);
Description
Retrieves the enumerated name for the device referenced by iIndex.
An enumerated name is a manufactured name made up of the driver name, vendor
id, product id & a reference number ensuring that each name on the USB is unique.
The name can be up to 512 bytes long although more normally it will be between
20~40 characters.
A call to EnumPrinters must have been made prior to calling this function
Arguments
iIndex – The index of the device. This must be an integer value
>=0<GetEnumPrinterCount();
If this value is outside of this range then an exception will be thrown.
Returns
An LPSTR pointer value pointing to the null terminated string representing the
enumerated name. The system error code will be set to ERROR_SUCCESS
regardless of whether the product id is valid or not.
The user should not delete this pointer or modify the contents pointed to directly.
Example
//Check range prior to call
if(
iDevIndex>=0&&iDevIndex< GetEnumPrinterCount)
{
LPSTR
pNameStr=GetName(iDevIndex);
//Display results
TRACE(_T(“Enumerated Name for device index %d is %S.\n”),
iDevIndex,pNameStr);
}