I'm trying to use a function that calls SetupDiGetDeviceRegistryProperty with Delphi 7. The call is from the example function SetupEnumAvailableComPorts. It looks like this:
SetupDiGetDeviceRegistryProperty(
DevInfoHandle,
DeviceInfoData,
RegProperty,
@PropertyRegDataType,
nil,
0,
@RequiredSize
);
I get the error "Types of actual and formal parameters must be identical" on the parameters @PropertyRegDataType, and @RequiredSize. These parameters are declared:
var
RequiredSize: Cardinal;
PropertyRegDataType: DWORD;
MSDN describes these parameters as: "RequiredSize [out, optional] A pointer to a variable of type DWORD that receives the required size, in bytes, of the PropertyBuffer buffer that is required to hold the data for the requested property. This parameter is optional and can be NULL." and "PropertyRegDataType [out, optional] A pointer to a variable that receives the data type of the property that is being retrieved. This is one of the standard registry data types. This parameter is optional and can be NULL."
The declaration of SetupDiGetDeviceRegistryProperty (in SetupAPI.pas from JVCL) looks like:
function SetupDiGetDeviceRegistryProperty(
DeviceInfoSet: HDEVINFO;
const DeviceInfoData: TSPDevInfoData;
Property_: DWORD;
var PropertyRegDataType: DWORD;
PropertyBuffer: PBYTE;
PropertyBufferSize: DWORD;
var RequiredSize: DWORD
): BOOL; stdcall; {$EXTERNALSYM SetupDiGetDeviceRegistryProperty}
Since PropertyRegDataType and RequiredSize are var parameters, they should be able to be passed without the @ operator. In fact, if I remove the @ operators from the function call parameters, the code compiles, but crashes with an access violation (read of address 0). The original code was written for Delphi 7, so why would they use the @ operator on these parameters? What am I missing?