Click here to Skip to main content
15,910,009 members
Home / Discussions / COM
   

COM

 
GeneralRe: AddRef() Error Pin
User 21559724-Aug-05 17:24
User 21559724-Aug-05 17:24 
GeneralCopy and pest Pin
dubotz22-Aug-05 3:42
dubotz22-Aug-05 3:42 
GeneralRe: Copy and pest Pin
MohammadAmiry30-Aug-05 9:33
MohammadAmiry30-Aug-05 9:33 
GeneralRe: Copy and pest Pin
dubotz30-Aug-05 22:35
dubotz30-Aug-05 22:35 
GeneralRe: Copy and pest Pin
dubotz31-Aug-05 0:16
dubotz31-Aug-05 0:16 
GeneralRe: Copy and pest Pin
MohammadAmiry2-Sep-05 7:36
MohammadAmiry2-Sep-05 7:36 
GeneralRe: Copy and pest Pin
Anonymous19-Oct-05 20:40
Anonymous19-Oct-05 20:40 
GeneralWindows Management Instrumentation Pin
rajeevktripathi22-Aug-05 1:53
rajeevktripathi22-Aug-05 1:53 
Hi all

I am using WMI(Windows Management Instrumentation) to extract varios system information, here when it returns VT_NULL, and I try to assign this variant type variable to a structure then memory access violation error appears.

The code snippet is as follows:


IEnumWbemClassObject * pEnumObjectStorageDevice = NULL;
HRESULT hResStorageDevice;



BSTR strQueryStorageDevice = (L"Select * from Win32_LogicalDisk");
BSTR strQLStorageDevice = (L"WQL");
hResStorageDevice = pWbemServices->ExecQuery(strQLStorageDevice, strQueryStorageDevice,WBEM_FLAG_RETURN_IMMEDIATELY,NULL,&pEnumObjectStorageDevice);

if(hResStorageDevice != S_OK)
{
MessageBox("Could not execute Query");
return;
}


ULONG uCountStorageDevice = 20, uReturnedStorageDevice;
IWbemClassObject* pClassObjectStorageDevice;//[20]; // = NULL;

i=0;
while (pEnumObjectStorageDevice)
{
HRESULT hr = pEnumObjectStorageDevice->Next(WBEM_INFINITE, 1,&pClassObjectStorageDevice, &uReturnedStorageDevice);
int a = GetLastError( );

if(uReturnedStorageDevice == 0)
{
break;
}

VARIANT vStorageDeviceDriveLetter,vStorageDeviceDriveType,vFileSystem;
VARIANT vDriveSize,vFreeSpace;

BSTR strClassPropStorageDevice = SysAllocString(L"Caption");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, &vStorageDeviceDriveLetter, 0, 0);

strClassPropStorageDevice = SysAllocString(L"Description");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, &vStorageDeviceDriveType, 0, 0);

strClassPropStorageDevice = SysAllocString(L"FileSystem");
HRESULT hrFileSystem = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, (&vFileSystem), 0, 0);

strClassPropStorageDevice = SysAllocString(L"Size");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, (&vDriveSize), 0, 0);

strClassPropStorageDevice = SysAllocString(L"FreeSpace");
hr = pClassObjectStorageDevice->Get(strClassPropStorageDevice, 0, (&vFreeSpace), 0, 0);

StructStorageDeviceInfo[i].strDriveLetter = vStorageDeviceDriveLetter;
StructStorageDeviceInfo[i].strDriveType = vStorageDeviceDriveType;
StructStorageDeviceInfo[i].strDriveFileSystem = vFileSystem;
StructStorageDeviceInfo[i].strDriveSize = vDriveSize;

i++;
VariantClear(&vStorageDeviceDriveLetter);
VariantClear(&vStorageDeviceDriveType);
VariantClear(&vFileSystem);
VariantClear(&vDriveSize);
VariantClear(&vFreeSpace);
}



Here when this program enumerate A: and there is no disk in FDD, then in case of "File System, Drive Size & Free Space" it returns VT_NULL and in line
StructStorageDeviceInfo[i].strDriveFileSystem = vFileSystem;

Memory access violation error appears .


Please suggest me to overcomr this problem.


Thanks & Regards.
Edit/Delete Message
GeneralRe: Windows Management Instrumentation Pin
MailtoGops22-Aug-05 5:57
MailtoGops22-Aug-05 5:57 
GeneralRe: Windows Management Instrumentation Pin
MailtoGops22-Aug-05 5:57
MailtoGops22-Aug-05 5:57 
GeneralEx2K : Event Sink Registration - Access Denied Pin
Michael B. Hansen22-Aug-05 0:28
Michael B. Hansen22-Aug-05 0:28 
GeneralLoad printers using COM+ from user profile Pin
Member 77854319-Aug-05 11:01
Member 77854319-Aug-05 11:01 
GeneralDifference in the compiling modes Pin
Logan from Singapore18-Aug-05 17:55
Logan from Singapore18-Aug-05 17:55 
GeneralRe: Difference in the compiling modes Pin
Steve S22-Aug-05 1:01
Steve S22-Aug-05 1:01 
GeneralRe: Difference in the compiling modes Pin
Logan from Singapore22-Aug-05 15:41
Logan from Singapore22-Aug-05 15:41 
GeneralMarshalling problem Pin
David_Leikis18-Aug-05 11:31
David_Leikis18-Aug-05 11:31 
GeneralRe: Marshalling problem Pin
Vi218-Aug-05 19:54
Vi218-Aug-05 19:54 
GeneralRe: Marshalling problem Pin
David_Leikis19-Aug-05 3:26
David_Leikis19-Aug-05 3:26 
GeneralRe: Marshalling problem Pin
Vi219-Aug-05 4:17
Vi219-Aug-05 4:17 
GeneralRe: Marshalling problem Pin
David_Leikis19-Aug-05 4:42
David_Leikis19-Aug-05 4:42 
GeneralRe: Marshalling problem Pin
Vi222-Aug-05 21:59
Vi222-Aug-05 21:59 
GeneralRe: Marshalling problem Pin
RikaBoy26-Aug-05 21:45
RikaBoy26-Aug-05 21:45 
General[Message Deleted] Pin
RikaBoy26-Aug-05 21:18
RikaBoy26-Aug-05 21:18 
GeneralRe: Marshalling problem Pin
Lim Bio Liong19-Aug-05 3:12
Lim Bio Liong19-Aug-05 3:12 
GeneralRe: Marshalling problem Pin
David_Leikis19-Aug-05 3:38
David_Leikis19-Aug-05 3:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.