Microsoft Developer Network > Forenhomepage > Visual C++ General > Cannot get OpenVirtualDisk working
Stellen Sie eine FrageStellen Sie eine Frage
 

BeantwortetCannot get OpenVirtualDisk working

  • Montag, 24. August 2009 05:59gift_of_seasons TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     
    I just installed Windows 7 SDK and am trying to get OpenVirtualDisk working with ISO files (I can get it working with VHDs). Here is the code: 
    	VIRTUAL_STORAGE_TYPE vstorType = {
    
    		VIRTUAL_STORAGE_TYPE_DEVICE_ISO
    
    		//VIRTUAL_STORAGE_TYPE_DEVICE_VHD
    
    		, {0xec984aec, 0xa0f9, 0x47e9, 0x90, 0x1f, 0x71, 0x41, 0x5a, 0x66, 0x34, 0x5b}}; //VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT;
    
    	OPEN_VIRTUAL_DISK_PARAMETERS openParams = {
    
    		OPEN_VIRTUAL_DISK_VERSION_1
    
    		//OPEN_VIRTUAL_DISK_VERSION_UNSPECIFIED
    
    		, {0}};
    
    	HANDLE h = 0;
    
    
    
    	DWORD dw = OpenVirtualDisk(&vstorType, _T("c:\\temp\\test.iso"),
    
    		//VIRTUAL_DISK_ACCESS_ATTACH_RO, 
    
    		VIRTUAL_DISK_ACCESS_READ,
    
    		OPEN_VIRTUAL_DISK_FLAG_NONE, &openParams, &h);
    
    	if(dw)
    
    	{
    
    		LastError err(dw);
    
    		_putts(err);
    
    	}
    
    	else
    
    	{
    
    		ATTACH_VIRTUAL_DISK_PARAMETERS attachParams = {ATTACH_VIRTUAL_DISK_VERSION_1, 0};
    
    		dw = AttachVirtualDisk(h, 0, ATTACH_VIRTUAL_DISK_FLAG_READ_ONLY, 0, &attachParams, 0);
    
    		if(dw)
    
    		{
    
    			LastError err(dw);
    
    			_putts(err);
    
    		}
    
    		else
    
    		{
    
    			DetachVirtualDisk(h, DETACH_VIRTUAL_DISK_FLAG_NONE, 0);
    
    			CloseHandle(h);
    
    		}
    
    	}
    
    



    The problems are:

    0. According to the SDK docs, I should include <windows.h> as usual. But it turned out Windows.h does not have virtdisk.h. But this problem is easy to correct.

    Minimum supported client Windows 7
    Minimum supported server Windows Server 2008 R2
    Header Virtdisk.h (include Windows.h)
    Library Virtdisk.lib
    DLL Virtdisk.dll

    1. Linker cannot find VIRTUAL_STORAGE_TYPE_VENDOR_MICROSOFT, so I have to copy/paste from virtdisk.h.
    2. OpenVirtualDisk returns 0xc03a0014 - A virtual disk support provider for the specified file was not found.

    What am I doing wrong?

     

Antworten

  • Montag, 24. August 2009 17:35nobugzMVP, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    Quoting from this article:

    Keep in mind that the API is designed to allow Microsoft to add support for additional formats in the future. In fact, support for the ISO optical disk image format has been considered but has not been added as of the Windows 7 beta. I hope that the necessary virtual disk support provider will be included in the release build. This would allow users to attach and mount ISO images as read-only hard drives.

    Pretty sure that didn't happen, no sign of it in Ultimate.  I wish it did.

    Hans Passant.

Alle Antworten

  • Montag, 24. August 2009 17:35nobugzMVP, ModeratorTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Beantwortet
    Quoting from this article:

    Keep in mind that the API is designed to allow Microsoft to add support for additional formats in the future. In fact, support for the ISO optical disk image format has been considered but has not been added as of the Windows 7 beta. I hope that the necessary virtual disk support provider will be included in the release build. This would allow users to attach and mount ISO images as read-only hard drives.

    Pretty sure that didn't happen, no sign of it in Ultimate.  I wish it did.

    Hans Passant.
  • Donnerstag, 29. Oktober 2009 20:06bodak TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Vorgeschlagene Antwort

    gift_of_seasons,

    I just ran into the same problem with SDK7.0 posted on 8/24/09.
    Did you figure this out? Do you know any solution?

    Thanks
    KB.

  • Mittwoch, 4. November 2009 21:13Mark Amos - MSFT TeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillenTeilnehmermedaillen
     Vorgeschlagene Antwort
    <Sorry, I unintentionally proposed bodak's post as an answer, please disregard that>

    Bodak, if you are trying to use the VIRTUAL_STORAGE_TYPE_DEVICE_ISO value as gift_of_seasons was, note the answer from nobugz. Supporting document is as follows:

    http://msdn.microsoft.com/en-us/library/dd323704(VS.85).aspx

    If you are not using this unsupported value but are still having problems building, you may need to define WINVER as _WIN32_WINNT_WIN7. 

    For more information on using header files to target various versions of Windows, see Using Windows Headers at the following location:

    http://msdn.microsoft.com/en-us/library/aa383745(VS.85).aspx

    Thank you,
    -Mark Amos