Note that there are some explanatory texts on larger screens.

plurals
  1. POWindows Structured Storage - 32-bit vs 64-bit COM Interop
    text
    copied!<p>While attempting to convert an existing 32-bit application to 64-bit, I've run into trouble getting some COM Interop code to work properly. The code is accessing the structured storage API, using managed code I translated from the various Windows SDK header/IDL files.</p> <p>The code is failing when I try to call into <code>IPropertyStorage.ReadMultiple()</code>, with <code>STG_E_INVALIDPARAMETER</code>. The previous interop calls, to <code>StgOpenStorageEx</code> and <code>IPropertySetStorage.Open</code>, appear to work fine. MSDN claims this error means something's wrong with my PROPSPEC parameters, but the same parameter values work fine when compiled as a 32-bit application and the value I get back is the correct string value for the specified property.</p> <p>Here are what I think are the relevant bits:</p> <pre class="lang-cs prettyprint-override"><code>// PropertySpecKind enumeration. public enum PropertySpecKind : uint { Lpwstr = 0, PropId = 1 } // PropertySpec structure: [StructLayout(LayoutKind.Explicit)] public struct PropertySpec { [FieldOffset(0)] public PropertySpecKind kind; [FieldOffset(4)] public uint propertyId; [FieldOffset(4)] public IntPtr name; } // PropertyVariant Structure: [StructLayout(LayoutKind.Explicit)] public struct PropertyVariant { [FieldOffset(0)] public Vartype vt; [FieldOffset(8)] public IntPtr pointerValue; } // IPropertyStorage interface [ComImport] [Guid("00000138-0000-0000-C000-000000000046")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPropertyStorage { int ReadMultiple( uint count, [MarshalAs(UnmanagedType.LPArray, SizeConst = 0)] PropertySpec[] properties, [Out, MarshalAs(UnmanagedType.LPArray, SizeConst = 0)] PropertyVariant[] values); void WriteMultiple( uint count, [MarshalAs(UnmanagedType.LPArray, SizeConst = 0)] PropertySpec[] properties, [MarshalAs(UnmanagedType.LPArray, SizeConst = 0)] PropertyVariant[] values, uint miniumumPropertyId); } var properties = new PropertySpec[1]; properties[0].kind = PropertySpecKind.PropId; properties[0].propertyId = 2; var propertyValues = new PropertyVariant[1]; // This helper method just calls StgOpenStorageEx with appropriate parameters. var propertySetStorage = StorageHelper.GetPropertySetStorageReadOnly(fileName); var propertyStorage = propertySetStorage.Open(StoragePropertySets.PSGUID_SummaryInformation, StorageMode.Read | StorageMode.ShareExclusive); propertyStorage.ReadMultiple(1, properties, propertyValues); // Exception is here. </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload