Call
GetLastError()
when the function fails. The error code might help finding out what is wrong. I guess it is invalid parameter here.
Note that
all parameters of the API function are pointers. So it should be probably (not tested):
[DllImport("Setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
internal static extern bool SetupDiGetClassImageIndex(ref SP_CLASSIMAGELIST_DATA ClassImageListData, Guid ClassGuid, ref int ImageIndex);
The conversion of the C# Guid to the C GUID structure pointer should be AFAIK done by P/Invoke automatically.
Your GUID is hopefully valid because otherwise an exception would be thrown by the
Guid()
constructor.