Click here to Skip to main content
15,884,739 members
Articles / Programming Languages / C++

System Information Utility

Rate me:
Please Sign up or sign in to vote.
4.95/5 (12 votes)
17 Apr 2001 500.5K   8.6K   107  
Utility to extract system information
// Disclaimer and Copyright Information
// StorageMediaInformation.h : Declaration of the CStorageMediaInformation 
//
// All rights reserved.
//
// Written by Naveen K Kohli (naveenkohli@netzero.net)
// Version 1.0
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
// naveenkohli@netzero.net
///////////////////////////////////////////////////////////////////////////////

#ifndef __STORAGEMEDIAINFORMATION_H_
#define __STORAGEMEDIAINFORMATION_H_

#include "resource.h"       // main symbols

class ATL_NO_VTABLE CStorageMediaInformation : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CStorageMediaInformation, &CLSID_StorageMediaInformation>,
	public ISupportErrorInfo,
	public IDispatchImpl<IStorageMediaInformation, &IID_IStorageMediaInformation, &LIBID_SYSTEMSTORAGELib>
{
public:
	CStorageMediaInformation()
	{
		m_bInformationObtained = false;
		m_NumberOfDrives = 0;
	}

DECLARE_REGISTRY_RESOURCEID(IDR_STORAGEMEDIAINFORMATION)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CStorageMediaInformation)
	COM_INTERFACE_ENTRY(IStorageMediaInformation)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

// ISupportsErrorInfo
	STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);

// IStorageMediaInformation
public:
	STDMETHOD(GetStorageMediaInformation)(/*[out]*/ long *plNumberOfDrives,
		/*[out]*/ VARIANT *pbReadyArr,  /*[out]*/ VARIANT *pbstrDriveLetterArr,
		/*[out]*/ VARIANT *pbstrLabelArr, /*[out]*/ VARIANT *pbSupportLongNameArr,
		/*[out]*/ VARIANT *pbstrFileSystemArr, /*[out]*/ VARIANT *pbstrMediaTypeArr,
		/*[out]*/ VARIANT *plTotalSpaceArr, /*[out]*/ VARIANT *plFreeSpaceUserArr,
		/*[out]*/ VARIANT *plFreeSpaceTotalArr);
	STDMETHOD(get_NumberOfDrives)(/*[out, retval]*/ long *pVal);

private:
	bool m_bInformationObtained;

	long m_NumberOfDrives;
	SAFEARRAY *m_pbDriveReady;
	SAFEARRAY *m_pbstrDriveLetter;
	SAFEARRAY *m_pbSupportLongName;
	SAFEARRAY *m_pbstrFileSystem;
	SAFEARRAY *m_pbstrDriveLabel;
	SAFEARRAY *m_pbstrMediaType;
	SAFEARRAY *m_plTotalSpace;
	SAFEARRAY *m_plFreeSpaceUser;
	SAFEARRAY *m_plFreeSpaceTotal;

	HRESULT GetInformation ();
	CComBSTR GetMediaType (DWORD dwType) const;
	HRESULT InitializeSafeArrays ();
};

#endif //__STORAGEMEDIAINFORMATION_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions