|
//////////////////////////////////////////////////////////////////////
// COMEnum.h: interface for the CCOMEnum class.
//
//////////////////////////////////////////////////////////////////////
// Copyright � 2005 Advatronix LLC
//
// With all inquiries please e-mail to:
// contact@advatronix.com
// or
// advatronix@yahoo.com
//////////////////////////////////////////////////////////////////////
// This code provided for non-commercial use only! As such it can be
// compiled and distributed in compiled form ONLY for "not for profit"
// applications ONLY!
//
// Re-distribution of the source code itself modified or unmodified is
// strictly prohibited without prior authorization!
//
// This code/software provided "AS IS" with no expressed or implied warranties.
// In no event should Advatronix LLC or its affiliates be liable for any
// direct, indirect, incidental, special, exemplary, or consequential
// damages of any kind, or any damages whatsoever, including, without
// limitation, those resulting from loss of use, data or profits,
// arising in any way out of the use of this software, even if
// advised of possibility of such damage.
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMENUM_H__93F1FC87_21D6_426C_AA0E_AC571557AA43__INCLUDED_)
#define AFX_COMENUM_H__93F1FC87_21D6_426C_AA0E_AC571557AA43__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//--------------------------------------------
// Error codes for registry accesses
//--------------------------------------------
#define REG_NOERROR 0
#define REG_HKEY_ERROR 1
#define REG_NOKEY_ERROR 2
#define REG_KEYREAD_ERROR 3
class CCOMEnum
{
// Custom Types
protected:
struct COMINFOEX
{
CString sPortName; // such as COM1
int iPortIndex; // such as 1
CString sPortKey; // such as "Drivers\BuitIn\Serial"
};
//Variables
protected:
UINT m_iTotalCOMs; // Holds total number of ports found
COMINFOEX *m_pInfoAr; // Info Array pointer
UINT m_RegError; // Holds Registry access error codes
//Methods
public:
CCOMEnum();
virtual ~CCOMEnum();
virtual void EnumerateCOMs(BOOL Verify);
inline virtual UINT GetTotalComs(void) { return m_iTotalCOMs; };
inline virtual int GetPortIndex(UINT ArIndex) { if(ArIndex < m_iTotalCOMs) return m_pInfoAr[ArIndex].iPortIndex; return 0;};
inline virtual CString GetPortName(UINT ArIndex) { if(ArIndex < m_iTotalCOMs) return m_pInfoAr[ArIndex].sPortName; return "";};
inline virtual CString GetPortKey(UINT ArIndex) { if(ArIndex < m_iTotalCOMs) return m_pInfoAr[ArIndex].sPortKey; return "";};
virtual CString GetPortSimpleKey(UINT ArIndex);
protected:
CString ReggyReadString(HKEY hkeyParent, LPCTSTR pSubkey, LPCTSTR pcszKey);
int ExtractPortIndex(CString portName);
BOOL VerifyHandle(CString portName);
};
#endif // !defined(AFX_COMENUM_H__93F1FC87_21D6_426C_AA0E_AC571557AA43__INCLUDED_)
|
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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.