Click here to Skip to main content
15,899,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I use the IVdsService interface to get the IVdsSwProvider, but thought QueryPacks to get the pack show that the pack is offline, and QueryDisk / QueryVolumes FAILED.

the Error line is in the
block
//*************************
// Error info
//*************************

//////////////////////////////////////////////////////////////////
	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);

//*******************
pPackProp show the Pack is Offline
//*******************
				//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);
//*******************
hResult  is S_FALSE
//*******************
						if(!SUCCEEDED(hResult))
						_SafeRelease(ppObjUnk);
					
				}
				_SafeRelease(pEnumVdsObject);
				_SafeRelease(ppObjUnk);
				_SafeRelease(pVdsPack);
				_SafeRelease(pVdsSwProvider);
}
///////////////////////////////////////////////////////////////////

#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;
 }
}
Posted
Updated 1-Aug-10 22:16pm
v2
Comments
Richard MacCutchan 2-Aug-10 3:59am    
Please format your code properly (put between <pre></pre> tags. Also check the actual error code when you get a failure and give its value and show which line it occurs on.
ocb0123 2-Aug-10 4:16am    
OK

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900