Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CreatePartition using VDS interface throw error "E_NOINTERFACE"

147 views
Skip to first unread message

venki

unread,
Jul 7, 2010, 10:03:31 AM7/7/10
to
Hi

I am developing application to Create Partition using VDS interface,
While execute the code it throws error "E_NOINTERFACE"

i have attached code,

it throws error the following line " hResult = ppObjUnk-
>QueryInterface(IID_IVdsAdvancedDisk,(void**)&ivdsAdvDisk);"

// VDSLocal.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "initguid.h"
#include "vds.h"
#include <stdio.h>

#pragma comment( lib, "ole32.lib" )

//
// Simple macro to release non-null interfaces.
//
#define _SafeRelease(x) {if (NULL != x) { x->Release(); x = NULL; } }

void __cdecl main(void)
{
HRESULT hResult;
IVdsService *pService = NULL;
IVdsServiceLoader *pLoader = NULL;
IVdsAsync *ivdsAsync=NULL;
IUnknown* ppObjUnk ;
SET_PARTITION_INFORMATION info;
HANDLE hDevice;
ULONG ulFetched = 0;


IVdsAdvancedDisk *ivdsAdvDisk=NULL;
IVdsSwProvider* pVdsSwProvider = NULL;
CREATE_PARTITION_PARAMETERS parType;
parType.MbrPartInfo.partitionType = PARTITION_IFS;
//parType.MbrPartInfo.bootIndicator = 0;

// For this, you first get a pointer to the VDS Loader
// Launch the VDS service.
//

hDevice = CreateFile(L"\\\\.\\PhysicalDrive1",GENERIC_READ |
GENERIC_WRITE,0,NULL, OPEN_EXISTING,
FILE_FLAG_WRITE_THROUGH | FILE_FLAG_NO_BUFFERING/
*FILE_ATTRIBUTE_NORMAL*/, NULL);

if(hDevice == INVALID_HANDLE_VALUE)
{
printf("could not open the drive");
}

hResult = CoInitialize(NULL);

if (SUCCEEDED(hResult))
{

hResult = CoCreateInstance(CLSID_VdsLoader,
NULL,
CLSCTX_LOCAL_SERVER,
IID_IVdsServiceLoader,
(void **) &pLoader);

//
// And then load VDS on the local computer.
//
if (SUCCEEDED(hResult))
{
hResult = pLoader->LoadService(NULL, &pService);
}

//
// You're done with the Loader interface at this point.
//
_SafeRelease(pLoader);

if (SUCCEEDED(hResult))
{
hResult = pService->WaitForServiceReady();
if (SUCCEEDED(hResult))
{
printf("VDS Service Loaded");
IEnumVdsObject* pEnumVdsObject = NULL;
hResult = pService-
>QueryProviders(VDS_QUERY_SOFTWARE_PROVIDERS,&pEnumVdsObject);
IUnknown* ppObjUnk=NULL ;

if (SUCCEEDED(hResult))
{
hResult = pEnumVdsObject->Next(1, &ppObjUnk, &ulFetched);

hResult = ppObjUnk->QueryInterface(IID_IVdsAdvancedDisk,
(void**)&ivdsAdvDisk);
if(SUCCEEDED(hResult))
{
_SafeRelease(ppObjUnk);
ivdsAdvDisk->CreatePartition(0,5368709120,&parType,&ivdsAsync);
}
}

}

}
else
{
printf("VDS Service failed hr=%x\n",hResult);
}
}
}

Pls advise me. any body sample code pls share with me.

Regards
Venki

0 new messages