how to get access a serial number of a USB disk

Discussion in 'Windows Vista Drivers' started by in yeanjin, Mar 29, 2005.

  1. in yeanjin

    in yeanjin Guest

    I am wondering how to get access a serial number of a USB disk on my PC.
    The serial number should be the same as a manufacturer's SN number on the
    disk label.
    Would any of you out there know the method for this please let me know.

    Many thanks.

    Dongho Song
    in yeanjin, Mar 29, 2005
    1. Advertisements

  2. The answer to 'a USB disk' is that you can't. The vendor of the logic in
    the device may or may not have a vendor command to get the serial number,
    but it is unique to each company.
    David J. Craig, Mar 29, 2005
    1. Advertisements

  3. You enumerate the Volumes with the SetupDi functions as usual.
    Then you check with CM_Get_Parent if the grandparent device is
    on the USB bus. This gives you all USB sticks.
    Then you get the "SymbolicName" registry entry and extract the USB
    SerialNumber string from it.

    Sorry, this is Delphi code:

    function GetSymbolicName(Inst: DEVINST): string;
    Len: DWORD;
    Key: HKEY;
    // a hopefully sufficiently large buffer
    Buffer: array [0..4095] of Char;
    CM_Open_DevNode_Key(Inst, KEY_READ, 0,
    REGDISPOSITION(RegDisposition_OpenExisting), Key, 0);
    Buffer[0] := #0;
    if Key <> INVALID_HANDLE_VALUE then
    Len := SizeOf(Buffer);
    RegQueryValueEx(Key, 'SymbolicName', nil, nil, @Buffer[0], @Len);
    Result := Buffer;
    Robert Marquardt, Mar 29, 2005
  4. in yeanjin

    Ray Trent Guest

    Just remember that the USB serial number probably has nothing to do with
    the serial number printed on the label. There's no general way to get
    that, though some vendors might provide one.

    Ray Trent, Apr 4, 2005
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.