none
VDS , How to use IVdsDisk to get the disk prop ( 获取Disk的属性 )? RRS feed

  • 常规讨论

  • 我使用IVdsService 接口获取到IVdsSwProvider, 但通过QueryPacks得到的pack显示Offline, 并且QueryDisks / QueryVolumes失败。请指教。

     

    	HRESULT hResult;
    	IVdsService* pService = NULL;
    	IVdsServiceLoader *pLoader = NULL;
    
    	//Launch the VDS Service
    	hResult = CoInitializeEx(NULL, COINIT_MULTITHREADED);
    
    	  // Initialize COM security
      CoInitializeSecurity(
          NULL,              // Allow *all* VSS writers to communicate back!
          -1,               // Default COM authentication service
          NULL,              // Default COM authorization service
          NULL,              // reserved parameter
          RPC_C_AUTHN_LEVEL_PKT_PRIVACY, // Strongest COM authentication level
          RPC_C_IMP_LEVEL_IMPERSONATE,    // Minimal impersonation abilities 
          NULL,              // Default COM authentication settings
          EOAC_NONE,           // No special options
          NULL              // Reserved parameter
          );
    
    	BOOL tx = SetConsoleCtrlHandler( (PHANDLER_ROUTINE) CtrlHandler, TRUE );
    
    	if( SUCCEEDED(hResult) )
    	{
    		hResult = CoCreateInstance( 
    									CLSID_VdsLoader,
    									NULL,
    									CLSCTX_LOCAL_SERVER,
    									IID_IVdsServiceLoader,
    									(void**) &pLoader
    									);
    		
    		//if succeeded load VDS on local machine
    		if( SUCCEEDED(hResult) )
    			pLoader->LoadService(NULL, &pService);
    
    		//Done with Loader now release VDS Loader interface
    		_SafeRelease(pLoader);
    
    		if( SUCCEEDED(hResult) )
    		{
    			hResult = pService->WaitForServiceReady();
    			if ( SUCCEEDED(hResult) )
    			{
    				//AfxMessageBox(L"VDS Service Loaded");
    				IEnumVdsObject* pEnumVdsObject = NULL;
    				hResult = pService->QueryProviders(VDS_QUERY_SOFTWARE_PROVIDERS, 
    &pEnumVdsObject);
    				hResult = pEnumVdsObject->Reset();
    
    
    				IUnknown* ppObjUnk ;
    				IVdsSwProvider* pVdsSwProvider = NULL;
    				IVdsPack* pVdsPack = NULL;
    				IVdsVolume* pVdsVolume = NULL;
    				ULONG ulFetched = 0;
    
    				hResult = E_INVALIDARG;
    				while(!SUCCEEDED(hResult))
    				{
    					hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched);
    					hResult = ppObjUnk->QueryInterface(IID_IVdsSwProvider , 
    (void**)&pVdsSwProvider);
    					if(!SUCCEEDED(hResult))
    						_SafeRelease(ppObjUnk);
    				}
    				_SafeRelease(pEnumVdsObject);
    				_SafeRelease(ppObjUnk);
    				
    				//VDS_PROVIDER_PROP pProviderProp;
    				//pVdsSwProvider->GetProperties(&pProviderProp);
    		
    				hResult = pVdsSwProvider->QueryPacks(&pEnumVdsObject);
    				hResult = pEnumVdsObject->Reset();
    
    				hResult = E_INVALIDARG;
    				while(!SUCCEEDED(hResult))
    				{
    					hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched);
    					hResult = ppObjUnk->QueryInterface(IID_IVdsPack, (void**)&pVdsPack);
    					if(!SUCCEEDED(hResult))
    						_SafeRelease(ppObjUnk);
    				}
    	
    				_SafeRelease(pEnumVdsObject);
    				_SafeRelease(ppObjUnk);
    
    				VDS_PACK_PROP pPackProp;
    				pVdsPack->GetProperties(&pPackProp);
    
    				//hResult = pVdsPack->QueryVolumes(&pEnumVdsObject);
    				hResult = pVdsPack->QueryDisks(&pEnumVdsObject);
    				hResult = pEnumVdsObject->Reset();
    				
    				hResult = E_INVALIDARG;
    				ulFetched = 0;
    				BOOL bDone = FALSE;
    				while(!SUCCEEDED(hResult))
    				{
    				
    					hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched);
    	// 失败
    
    
    						if(!SUCCEEDED(hResult))
    						_SafeRelease(ppObjUnk);
    
    					
    				}
    				_SafeRelease(pEnumVdsObject);
    				_SafeRelease(ppObjUnk);
    				_SafeRelease(pVdsPack);
    				_SafeRelease(pVdsSwProvider);
    2010年7月31日 18:16

全部回复

  • #define _SafeRelease(x) {if (NULL != x) { x->Release(); x = NULL; } }
    
    BOOL CtrlHandler( DWORD fdwCtrlType ) 
    { 
     switch( fdwCtrlType ) 
     { 
      // Handle the CTRL-C signal. 
      case CTRL_C_EVENT: 
       printf( "Ctrl-C event\n\n" );
       Beep( 750, 300 ); 
       return( TRUE );
     
      // CTRL-CLOSE: confirm that the user wants to exit. 
      case CTRL_CLOSE_EVENT: 
       Beep( 600, 200 ); 
       printf( "Ctrl-Close event\n\n" );
       return( TRUE ); 
     
      // Pass other signals to the next handler. 
      case CTRL_BREAK_EVENT: 
       Beep( 900, 200 ); 
       printf( "Ctrl-Break event\n\n" );
       return FALSE; 
     
      case CTRL_LOGOFF_EVENT: 
       Beep( 1000, 200 ); 
       printf( "Ctrl-Logoff event\n\n" );
       return FALSE; 
     
      case CTRL_SHUTDOWN_EVENT: 
       Beep( 750, 500 ); 
       printf( "Ctrl-Shutdown event\n\n" );
       return FALSE; 
     
      default: 
       return FALSE; 
     } 
    } 
     
    2010年7月31日 18:17
  • 顶一下。

    2010年8月1日 4:47