The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CM_Get_Device_ID_Ex function

[Beginning with Windows 8 and Windows Server 2012, this function has been deprecated. Please use CM_Get_Device_ID instead.]

The CM_Get_Device_ID_Ex function retrieves the device instance ID for a specified device instance on a local or a remote machine.


WINAPI CM_Get_Device_ID_Ex(
  _In_     DEVINST  dnDevInst,
  _Out_    PWSTR    Buffer,
  _In_     ULONG    BufferLen,
  _In_     ULONG    ulFlags,
  _In_opt_ HMACHINE hMachine


dnDevInst [in]

Caller-supplied device instance handle that is bound to the machine handle supplied by hMachine.

Buffer [out]

Address of a buffer to receive a device instance ID string. The required buffer size can be obtained by calling CM_Get_Device_ID_Size_Ex, then incrementing the received value to allow room for the string's terminating NULL.

BufferLen [in]

Caller-supplied length, in characters, of the buffer specified by Buffer.

ulFlags [in]

Not used, must be zero.

hMachine [in, optional]

Caller-supplied machine handle to which the caller-supplied device instance handle is bound.

Note  Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, as this functionality has been removed.

Return value

If the operation succeeds, the function returns CR_SUCCESS. Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h.


The function appends a NULL terminator to the supplied device instance ID string, unless the buffer is too small to hold the string. In this case, the function supplies as much of the identifier string as will fit into the buffer, and then returns CR_BUFFER_SMALL.

For information about device instance IDs, see Device Identification Strings.

For information about using device instance handles that are bound to a local or a remote machine, see CM_Get_Child_Ex.

Functionality to access remote machines has been removed in Windows 8 and Windows Server 2012 and later operating systems thus you cannot access remote machines when running on these versions of Windows.


Target platform



Available in Microsoft Windows 2000 and later versions of Windows.


Cfgmgr32.h (include Cfgmgr32.h)



Unicode and ANSI names

CM_Get_Device_ID_ExW (Unicode)

See also




Send comments about this topic to Microsoft