Click here to Skip to main content
15,878,945 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 499.9K   8.6K   107  
Utility to extract system information
// Disclaimer and Copyright Information
// MiscInformation.h : 
//
// 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
///////////////////////////////////////////////////////////////////////////////

// Revision History:
//	2/1/2001		Initial Creation
//	2/7/2001		Added IMiscInformation2 interface
//

#ifndef __MISCINFORMATION_H_
#define __MISCINFORMATION_H_

#include "resource.h"       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CMiscInformation
class ATL_NO_VTABLE CMiscInformation : 
	public CComObjectRootEx<CComSingleThreadModel>,
	public CComCoClass<CMiscInformation, &CLSID_MiscInformation>,
	public ISupportErrorInfo,
	public IDispatchImpl<IMiscInformation, &IID_IMiscInformation, &LIBID_SYSTEMMISCLib>,
	public IDispatchImpl<IMiscInformation2, &IID_IMiscInformation2, &LIBID_SYSTEMMISCLib>
{
public:
	CMiscInformation()
	{
		m_bInformationObtained = false;

		m_bstrComputerName = _T ("");
		m_bstrUserName = _T ("");
		m_bstrLocalLanguage = _T ("");
		m_bstrTimeZone = _T ("");
	}

DECLARE_REGISTRY_RESOURCEID(IDR_MISCINFORMATION)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CMiscInformation)
	COM_INTERFACE_ENTRY(IMiscInformation)
	COM_INTERFACE_ENTRY2(IDispatch, IMiscInformation)	// Use IDispatch implementation 
														// from IMiscInformation
	COM_INTERFACE_ENTRY(IMiscInformation2)
	COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()

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

// IMiscInformation
public:
	STDMETHOD(get_Language)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(get_SystemUserName)(/*[out, retval]*/ BSTR *pVal);
	STDMETHOD(get_SystemName)(/*[out, retval]*/ BSTR *pVal);
	STDMETHODIMP get_TimeZone(BSTR* pVal);

private:
	bool m_bInformationObtained;
	CComBSTR m_bstrComputerName;
	CComBSTR m_bstrUserName;
	CComBSTR m_bstrLocalLanguage;
	CComBSTR m_bstrTimeZone;

	HRESULT GetInformation ();
};

#endif //__MISCINFORMATION_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