   Detecting an USB.
  Hi everyone,I have the same requirement as in the thread at http://www.gamedev.net/community/forums/topic.asp?topic_id=362845&whichpage=1&#2387532I wish to determine the type of removable drive, when the drive letter is given. To detect an USB (as per MSDN), I use the 'SetupDiGetDeviceRegistryProperty' method with SPDRP_REMOVAL_POLICY as a parameter.(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devinst_r/hh/DevInst_r/di-rtns_a60fa017-1c15-45bf-a178-37516bc0aea1.xml.asp)MSDN says:"SPDRP_REMOVAL_POLICY    (Windows XP and later) The function retrieves the device's current removal policy as a DWORD containing one of the CM_REMOVAL_POLICY_Xxxx values defined in cfgmgr32.h."My problem:How does this function retrieve this value ? The Output parameter PropertyBuffer is of type PBYTE and when I type cast it and take the value as *((DWORD *)PropertyBuffer), it gives me an invalid value (some garbage other than the CM_REMOVAL_POLICY_ values defined in cfgmgr32.h)Can someone please help ??Thanks,Vinoth   
  You optimistically misunderstood the MSDN explanation.Says an easily googled MSDN page:Quote:Return ValueSetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError. SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a device or if the property data is not valid.So the return value is a generic status code; the important "result" is written into a team of output parameters:Quote:PropertyRegDataType    Supplies a pointer to a variable to receive the data type of the property being retrieved. This is one of the standard registry data types.PropertyBuffer    Supplies a pointer to a buffer to receive the property being retrieved. If set to NULL, with PropertyBufferSize set to zero, the function just returns a value for RequiredSize.PropertyBufferSize    Supplies the length, in bytes, of PropertyBuffer.RequiredSize    Optional. If not NULL, it is a caller-supplied pointer to a variable that receives the required size, in bytes, of the property buffer pointed to by PropertyBuffer, based on the property requested by Property.Isn't it a cute API?