Prev: Reading emails from distribution group and extract attachment
Next: using a String Builder a actual parameter and LPTSTR as formalparameter in unmanaged code
From: Tony Johansson on 29 Apr 2010 18:29 Hi The doc says the following text within "". Does this text mean that if an error occur and this property is set to false an exception is throw from the Windows32 API ? "This field indicates whether unmanaged methods that have HRESULT or retval return values are directly translated or automatically converted to exceptions. True: The method returns a value that contains the HRESULT. False: The method automatically converts HRESULT or retval values to exceptions. When you set the PreserveSig field to False, the resulting method signature contains a void return type instead of an integer (HRESULT) return type. The default value for this field is True."
From: Family Tree Mike on 29 Apr 2010 20:00
On 4/29/2010 6:29 PM, Tony Johansson wrote: > Hi > > The doc says the following text within "". Does this text mean that if an > error occur and this property is set to false an exception is throw from the > Windows32 API ? > > "This field indicates whether unmanaged methods that have HRESULT or retval > return values are directly translated or automatically converted to > exceptions. > > True: The method returns a value that contains the HRESULT. > > False: The method automatically converts HRESULT or retval values to > exceptions. > > When you set the PreserveSig field to False, the resulting method signature > contains a void return type instead of an integer (HRESULT) return type. > > The default value for this field is True." > > Technically, I believe the flag means the .Net code provided by the DllImport to call the method will intercept the HRESULT and convert it to a thrown exception. It is a layer between your managed caller and the unmanaged method that generates the exception. -- Mike |