Windows API Parameters in Delphi - passing var parameter with or without @ operator?
I'm trying to use a function that calls [SetupDiGetDeviceRegistryProperty][1] with Delphi 7. 
The call is from the example function [SetupEnumAvailableComPorts][2]. 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][3]) 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][4] was written for Delphi 7, so why would they use the @ operator on these parameters? What am I missing?


  [1]: http://msdn.microsoft.com/en-us/library/ff551967%28v=vs.85%29.aspx
  [2]: http://www.delphi3000.com/articles/article_4001.asp?SK=
  [3]: http://sourceforge.net/projects/jvcl/files/JVCL%203/JVCL%203.40/JVCL340CompleteJCL221-Build3845.zip/download
  [4]: http://www.delphi3000.com/articles/article_4001.asp?SK=
Windows API Parameters in Delphi - passing var parameter with or without @ operator?
===

I'm trying to use a function that calls [SetupDiGetDeviceRegistryProperty][1] with Delphi 7. 
The call is from the example function [SetupEnumAvailableComPorts][2]. 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][3]) 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][4] was written for Delphi 7, so why would they use the @ operator on these parameters? What am I missing?


  [1]: http://msdn.microsoft.com/en-us/library/ff551967%28v=vs.85%29.aspx
  [2]: http://www.delphi3000.com/articles/article_4001.asp?SK=
  [3]: http://sourceforge.net/projects/jvcl/files/JVCL%203/JVCL%203.40/JVCL340CompleteJCL221-Build3845.zip/download
  [4]: http://www.delphi3000.com/articles/article_4001.asp?SK=