Virtual Disk API After RC

I already wrote about Virtual disk API support in Windows 7. All that was based on beta so, now with Windows 7 RC in wild, some corrections are in order.

Microsoft decided to replace word surface with attach. While plenty of those changes were done in beta also (e.g. DISKPART), renaming of API functions was timed for release candidate. Since this change invalidates my previous code examples on how to work with virtual disks, here is new example that works with RC (but doesn’t work with beta).

Usual practice for release candidate is to be code-complete - hopefully no further API changes will be done before final version.

P.S. This code is work in progress, in no way it is production quality.

[2009-05-03: There was bug with one parameter in code. On beta, that bug went unnoticed, but on release candidate it causes open operation to fail with native error 87. I updated source code so all further downloads will point to correct files.]

[2009-06-12: There was change in enumerations from beta to RC that I missed. Side effect of it was inability to permanently attach virtual disk. This is fixed now (to make it more embarrassing, I used correct code in Open and attach sample but somehow I missed to notice the difference).]

Windows 7 RC

Release candidate is finally out for MSDN subscribers.

Thanks for subscription Marc. :)

XPM

Illustration

There is new feature in sight for Windows 7. It is called Windows XP Mode and it will allow you to run Windows XP applications in virtualized environment.

Nice thing about this will be that XP windows will just open without showing the whole XP desktop. This is quite significant since whenever virtualization is employed, some reeducation needs to be done. Now education will consist of simple: “Just click shortcut and window will appear.” line. For “standard” consumer, everything should look the same (ok, title bar is giveaway).

P.S. If this feature seems like something you saw somewhere, there is more-or-less same feature in VirtualBox. It is called seamless mode there.

AutoUpgradeEnabled

My program was failing with MissingMethodException (Method not found: ‘Void System.Windows.Forms.FileDialog.set_AutoUpgradeEnabled(Boolean)’). This happened only on Windows XP and not all of them.

Culprit was obvious. I used OpenFileDialog and I decided to set AutoUpgradeEnabled property. Only problem was that this property was introduced with .NET Framework 2.0 SP1. Notice this service pack part - that property does not exist if you have version without it.

Solution is easy if you are trying setting this property to true - that is default value anyhow. If you want to set it to false, just use reflection:

var property = typeof(FileDialog).GetProperty("AutoUpgradeEnabled");
if (property != null) {
  property.SetValue(openFileDialog1, false, null);
}

Notice that this property is shared among other controls inheriting from FileDialog (e.g. SaveFileDialog) so same thing applies to them also.