SetupDiClassNameFromGuid (setupapi)
Last changed: -99.24.187.145

.
Summary
The SetupDiClassNameFromGuid function retrieves the class name associated with a class GUID.

C# Signature:

[DllImport("setupapi.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern bool SetupDiClassNameFromGuid(
    Guid ClassGuid,
    StringBuilder ClassName,
    UInt32 ClassNameSize,
    out UInt32 RequiredSize
    );

Parameters

ClassGuid

The class GUID for the class name to retrieve.

ClassName

A pointer to a buffer that receives the NULL-terminated string that contains the name of the class that is specified by the pointer in the ClassGuid parameter.

ClassNameSize

The size, in characters, of the buffer that is pointed to by the ClassName parameter. The maximum size, in characters, of a NULL-terminated class name is MAX_CLASS_NAME_LEN. For more information about the class name size, see the following Comments section.

RequiredSize

A pointer to a variable that receives the number of characters that are required to store the requested NULL-terminated class name. This pointer is optional and can be NULL.

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

  StringBuilder className = null;
  uint classNameLen;
  SetupDiClassNameFromGuid(setupClass, className, 0, out classNameLen);
  className = new StringBuilder((int)classNameLen);
  if (!SetupDiClassNameFromGuid(setupClass, className, classNameLen, out classNameLen))
  {
    // Handle the error.
  }
  else
  {
    // Use the class name, e.g. Console.WriteLine(className.ToString());
  }

Documentation