亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? modeminfoclass.cpp

?? 串口通訊程序,已經通過實踐,可以長期穩定的工作,性能超好
?? CPP
字號:
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1999 by Seain B. Conover, Tarasoft Corporation
// All rights reserved
//
// Distribute freely. Absolutely do not 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.
//
// Read *Atlas Shrugged*, http://www.aynrand.org
//
/////////////////////////////////////////////////////////////////////////////


// ModemInfo.cpp : implementation file
//

#include "stdafx.h"
//#include "Titan.h"
#include "ModemInfoClass.h"

#include "RegistryEx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#define MAX_ENUM_COUNT		10

/////////////////////////////////////////////////////////////////////////////
// CModemInfo

CModemInfo::CModemInfo()
{
}

CModemInfo::~CModemInfo()
{
}

/////////////////////////////////////////////////////////////////////////////
// CModemInfo message handlers

const CString CModemInfo::GetProfileString( LPCTSTR lpszSection, LPCTSTR lpszEntry, LPCTSTR lpszDefault, HKEY hKey ) const
{
	CString strValue = lpszDefault;

	// get section key
	HKEY hSectionKey = NULL;
	::RegOpenKeyEx( hKey, lpszSection, 0, KEY_READ, &hSectionKey );

	// if section does not exist, return default
	if ( hSectionKey != NULL )
	{
		// get desired entry
		DWORD dwType = 0;
		DWORD dwCount = 0;

		if ( ::RegQueryValueEx( hSectionKey, (LPTSTR)lpszEntry, NULL, &dwType, NULL, &dwCount ) == ERROR_SUCCESS )
		{
			ASSERT( dwType == REG_SZ );
	
			if ( ::RegQueryValueEx( hSectionKey, (LPTSTR)lpszEntry, NULL, &dwType, (LPBYTE)strValue.GetBuffer( dwCount / sizeof( TCHAR ) ), &dwCount ) == ERROR_SUCCESS )
			{
				strValue.ReleaseBuffer();
			}
			else
			{
				strValue.ReleaseBuffer();
				strValue = lpszDefault; // just in case
			}
		}

		::RegCloseKey( hSectionKey );
	}

	return strValue;
}


const CString CModemInfo::GetPaddedIndex( const int nIndex ) const
{
	CString strIndex;
	strIndex.Format( "%d", nIndex );
	return CString( "0000" ).Left( 4 - strIndex.GetLength() ) + strIndex;
}

const int CModemInfo::GetModemIndex( CString strName ) const
{
	int nResult = -1;

	if ( !strName.IsEmpty() )
	{
		strName.MakeUpper();

		int nCount;
		for ( nCount = 0; nCount < MAX_ENUM_COUNT; nCount++ )
		{
			CString strGetModemName = GetModemName( nCount );
			strGetModemName.MakeUpper();
			if ( strName == strGetModemName && GetModemComPortByIndex( nCount ) > 0 )
			{
				nResult = nCount;
				break;
			}
		}
	}

	return nResult;
}

const BOOL CModemInfo::GetIsModem( const CString strName ) const
{
	return GetModemIndex( strName ) != -1;
}

const int CModemInfo::GetModemCount() const
{
	int nResult = 0;

	int nCount;
	for ( nCount = 0; nCount < MAX_ENUM_COUNT; nCount++ )
	{
		CString strName = GetModemName( nCount );
		if ( !strName.IsEmpty() && strName.Find( "IP Virtual Modem" ) == -1 ) // don't count COM/IP Virtual Modem
		{
			nResult++;
		}
	}

	return nResult;
}

const CString CModemInfo::GetModemClassGuid() const
{
//	return GetProfileString( "SYSTEM\\CurrentControlSet\\Enum\\Root\\MDMGEN\\" + GetFirstRegistrySubKey( HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Enum\\Root\\MDMGEN" ), "ClassGUID", "", HKEY_LOCAL_MACHINE );
	return "{4D36E96D-E325-11CE-BFC1-08002BE10318}";
}

const CString CModemInfo::GetModemRegistrySection( const int nIndex ) const
{
	CString strResult;

	OSVERSIONINFO osvi;
	osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO );
	GetVersionEx( &osvi );

	if ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS )
	{
		strResult = "SYSTEM\\CurrentControlSet\\Services\\Class\\Modem\\" + GetPaddedIndex( nIndex );
	}
	else
	{
		strResult = "SYSTEM\\CurrentControlSet\\Control\\Class\\" + GetModemClassGuid() + "\\" + GetPaddedIndex( nIndex );
	}

	return strResult;
}

const CString CModemInfo::GetFirstModemName() const
{
	CString strResult;

	int nCount;
	for ( nCount = 0; nCount < MAX_ENUM_COUNT; nCount++ )
	{
		CString strName = GetModemName( nCount );
		if ( !strName.IsEmpty() && strName.Find( "IP Virtual Modem" ) == -1 ) // don't add COM/IP Virtual Modem
		{
			strResult = strName;
			break;
		}
	}

	return strResult;
}

const CString CModemInfo::GetModemName( const int nIndex ) const
{
	return GetProfileString( GetModemRegistrySection( nIndex ), "Model", "", HKEY_LOCAL_MACHINE );
}

const CString CModemInfo::GetModemResetString( const CString strName ) const
{
	CString strResetString = GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ), "Reset", "", HKEY_LOCAL_MACHINE );
	
	CString strUpper = strResetString;
	strUpper.MakeUpper();
	if ( strUpper == "NONE" )
	{
		strResetString.Empty();
	}

	return strResetString;
}

const CString CModemInfo::GetModemInitString( const CString strName, const int nSpeakerVolume ) const
{
	CString strInit = "AT";

	const CString strKey = GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings";

	CString strCallSetupFailTimer = GetProfileString( strKey, "CallSetupFailTimer", "", HKEY_LOCAL_MACHINE );
	strCallSetupFailTimer.Replace( "<#>", "60" );

	CString strInactivityTimeout = GetProfileString( strKey, "InactivityTimeout", "", HKEY_LOCAL_MACHINE );
	strInactivityTimeout.Replace( "<#>", "0" );

	strInit += strCallSetupFailTimer + strInactivityTimeout;

	if ( nSpeakerVolume != -1 && GetModemHasSpeaker( strName ) )
	{
		const int nNumVolumeLevels = GetModemVolumeLevelsCount( strName );
		const CString strSpeakerOn = GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings", "SpeakerMode_Dial", "", HKEY_LOCAL_MACHINE );

		switch ( nSpeakerVolume )
		{
		case 0:
			strInit += GetProfileString( strKey, "SpeakerMode_OFF", "", HKEY_LOCAL_MACHINE );
			break;
		case 1:
			strInit += nNumVolumeLevels == 0 ? strSpeakerOn : GetProfileString( strKey, "SpeakerVolume_Low", "", HKEY_LOCAL_MACHINE ) + strSpeakerOn;
			break;
		case 2:
			strInit += nNumVolumeLevels > 0 ? GetProfileString( strKey, "SpeakerVolume_Med", "", HKEY_LOCAL_MACHINE ) + strSpeakerOn : "";
			break;
		case 3:
			strInit += nNumVolumeLevels > 0 ? GetProfileString( strKey, "SpeakerVolume_High", "", HKEY_LOCAL_MACHINE ) + strSpeakerOn : "";
			break;
		default:
			ASSERT( FALSE );
		}
	}

	strInit += GetProfileString( strKey, "ErrorControl_On", "", HKEY_LOCAL_MACHINE );
	strInit += GetProfileString( strKey, "Compression_On", "", HKEY_LOCAL_MACHINE );
	strInit += GetProfileString( strKey, "FlowControl_Hard", "", HKEY_LOCAL_MACHINE );
	strInit += GetProfileString( strKey, "Modulation_CCITT", "", HKEY_LOCAL_MACHINE );
	strInit += GetProfileString( strKey, "Blind_Off", "", HKEY_LOCAL_MACHINE );

	return strInit + "<cr>";
}

const BOOL CModemInfo::GetModemHasSpeaker( const CString strName ) const 
{
	return !GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings", "SpeakerMode_Dial", "", HKEY_LOCAL_MACHINE ).IsEmpty() &&
		   !GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings", "SpeakerMode_OFF", "", HKEY_LOCAL_MACHINE ).IsEmpty();
}

const int CModemInfo::GetModemVolumeLevelsCount( const CString strName ) const
{
	int nResult = 0;

	if ( !GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings", "SpeakerVolume_Low", "", HKEY_LOCAL_MACHINE ).IsEmpty() ) nResult++;
	if ( !GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings", "SpeakerVolume_Med", "", HKEY_LOCAL_MACHINE ).IsEmpty() ) nResult++;
	if ( !GetProfileString( GetModemRegistrySection( GetModemIndex( strName ) ) + "\\Settings", "SpeakerVolume_High", "", HKEY_LOCAL_MACHINE ).IsEmpty() ) nResult++;

	return nResult;
}

const CString CModemInfo::GetFirstRegistrySubKey( const HKEY hKey, const CString strSection ) const
{
	CString strResult;

	CRegistryEx RegistryEx;
	if ( RegistryEx.Open( hKey, "" ) )
	{
		CStringArray arSubKeys;
		if ( RegistryEx.ListKey( strSection, arSubKeys ) )
		{
			strResult = arSubKeys[ 0 ];
		}
		RegistryEx.Close();
	}
	
	return strResult;
}

const int CModemInfo::GetModemBps( const CString strName ) const
{
	int nResult = 0;

	CRegistryEx RegistryEx;
	if ( RegistryEx.Open( HKEY_LOCAL_MACHINE, GetModemRegistrySection( GetModemIndex( strName ) ) ) )
	{
		const int nSize = 255;
		char* pBuffer = new char[ nSize + 1];
		if ( RegistryEx.Read( "DCB", pBuffer, nSize ) )
		{
			memcpy( &nResult, &pBuffer[4], 4 );
			if ( nResult != 230400 &&
				 nResult != 115200 &&
				 nResult !=  57600 &&
				 nResult !=  38400 &&
				 nResult !=  19200 &&
				 nResult !=   9600 &&
				 nResult !=   4800 &&
				 nResult !=   2400 &&
				 nResult !=   1200 &&
				 nResult !=    300 &&
				 nResult !=    110 )
			{
				nResult = 0;
			}
		}
		delete [] pBuffer;
		RegistryEx.Close();
	}

	return nResult;
}

const int CModemInfo::GetModemComPortByIndex( const int nIndex ) const
{
	int nResult = 0;

	const CString strPort = GetProfileString( GetModemRegistrySection( nIndex ), "AttachedTo", "", HKEY_LOCAL_MACHINE );
	if ( !strPort.IsEmpty() )
	{
		nResult = atol( strPort.Mid( 3 ) );		// ie, COM3
	}
	else
	{
		CRegistryEx RegistryEx;
		if ( RegistryEx.Open( HKEY_LOCAL_MACHINE, "" ) )
		{
			CString strKey = RegistryEx.FindKey( "Enum", "Driver", "Modem\\" + GetPaddedIndex( nIndex ) );
			if ( !strKey.IsEmpty() )
			{
				const CString strPort = GetProfileString( strKey, "PORTNAME", "", HKEY_LOCAL_MACHINE );
				if ( !strPort.IsEmpty() )
				{
					nResult = atol( strPort.Mid( 3 ) );
				}
			}
			RegistryEx.Close();
		}
	}
		
	return nResult;
}

const int CModemInfo::GetModemComPort( const CString strName ) const
{
	return GetModemComPortByIndex( GetModemIndex( strName ) );
}

void CModemInfo::FillComboBoxWithModemNames( CComboBox* pComboBox )
{
	// delete exiting items
	while ( pComboBox->DeleteString( 0 ) != CB_ERR );

	// add all detected modems
	int nCount;
	for ( nCount = 0; nCount < MAX_ENUM_COUNT; nCount++ )
	{
		CString strName = GetModemName( nCount );
		if ( !strName.IsEmpty() && strName.Find( "IP Virtual Modem" ) == -1 ) // don't add COM/IP Virtual Modem
		{
			pComboBox->AddString( strName );
		}
	}
}

void CModemInfo::FillListBoxWithModemNames( CListBox* pListBox )
{
	// delete exiting items
	while ( pListBox->DeleteString( 0 ) != CB_ERR );

	// add all detected modems
	int nCount;
	for ( nCount = 0; nCount < MAX_ENUM_COUNT; nCount++ )
	{
		CString strName = GetModemName( nCount );
		if ( !strName.IsEmpty() && strName.Find( "IP Virtual Modem" ) == -1 ) // don't add COM/IP Virtual Modem
		{
			pListBox->AddString( strName );
		}
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲特黄一级片| 美女视频免费一区| 日韩精品一区在线观看| www.亚洲激情.com| 久久精品国产色蜜蜜麻豆| 亚洲精品欧美激情| 欧美激情在线一区二区三区| 911精品国产一区二区在线| 成人avav影音| 黑人巨大精品欧美一区| 亚洲一区二区三区国产| 综合亚洲深深色噜噜狠狠网站| 日韩精品专区在线影院观看| 欧美日韩在线播放一区| 99久久亚洲一区二区三区青草| 另类小说色综合网站| 亚洲国产一区视频| 亚洲免费av观看| 国产精品系列在线| 久久色视频免费观看| 日韩视频免费观看高清完整版在线观看 | 99精品视频中文字幕| 裸体在线国模精品偷拍| 亚洲aaa精品| 亚洲高清视频的网址| 亚洲精品久久久蜜桃| 国产精品久久久久久久久久久免费看 | 日韩欧美一区二区三区在线| 欧美午夜精品理论片a级按摩| 成人午夜电影小说| 国产一区高清在线| 精品在线观看视频| 日本女优在线视频一区二区| 天堂午夜影视日韩欧美一区二区| 夜夜操天天操亚洲| 亚洲免费在线电影| 亚洲另类在线一区| 亚洲精品视频观看| 亚洲一区二区三区四区在线 | 在线观看视频一区二区欧美日韩| av激情综合网| 91丨九色丨尤物| 欧美xxx久久| 26uuu亚洲综合色| 精品国产在天天线2019| 久久亚洲综合av| 久久精品欧美日韩| 国产精品免费av| 最新成人av在线| 亚洲精品网站在线观看| 亚洲一区二区三区三| 丝袜亚洲另类欧美综合| 日韩国产欧美三级| 韩国三级在线一区| 成人免费va视频| 色综合天天综合网国产成人综合天| 不卡的电影网站| 在线观看视频91| 日韩一区二区免费在线电影 | 国产日韩在线不卡| 亚洲欧美一区二区视频| 伊人一区二区三区| 日本亚洲免费观看| 国产精品一区二区久久不卡| 99久久精品情趣| 欧美人与z0zoxxxx视频| 日韩精品中午字幕| 国产精品久久免费看| 亚洲国产综合在线| 国产在线一区二区| 色婷婷综合久久久久中文| 在线播放91灌醉迷j高跟美女| 久久综合五月天婷婷伊人| 国产精品久久久久久福利一牛影视| 亚洲精品ww久久久久久p站| 日韩av电影一区| 不卡的av在线播放| 91精品一区二区三区久久久久久 | 韩国理伦片一区二区三区在线播放| 国产大片一区二区| 欧美日韩美少妇| 国产午夜精品一区二区三区嫩草| 亚洲柠檬福利资源导航| 久久99精品国产.久久久久| 97久久超碰精品国产| 欧美变态tickling挠脚心| 亚洲欧美中日韩| 美腿丝袜亚洲一区| 91麻豆国产香蕉久久精品| 日韩欧美亚洲一区二区| 一区二区在线免费观看| 国产精品中文字幕一区二区三区| 色婷婷亚洲综合| 久久精品夜色噜噜亚洲a∨| 亚洲一区二区三区四区的| 懂色av中文一区二区三区| 欧美乱妇15p| 国产精品成人免费精品自在线观看 | 91精品欧美久久久久久动漫| 亚洲欧美在线aaa| 国产美女在线观看一区| 欧美日韩国产在线观看| 中文字幕色av一区二区三区| 精品一区二区综合| 欧美日韩和欧美的一区二区| 国产精品久久久久久户外露出| 久久激情五月婷婷| 欧美人成免费网站| 亚洲主播在线播放| 99精品欧美一区二区蜜桃免费 | 日本一区二区电影| 国产在线乱码一区二区三区| 在线综合视频播放| 亚洲第一二三四区| 在线欧美一区二区| 亚洲欧美偷拍另类a∨色屁股| 国产大陆a不卡| 久久久精品蜜桃| 国产在线精品免费| 欧美变态tickling挠脚心| 日本成人在线电影网| 欧美日韩不卡一区| 亚洲chinese男男1069| 色噜噜久久综合| 亚洲同性gay激情无套| av福利精品导航| 亚洲国产精品成人久久综合一区| 国产精品自拍一区| 久久精品夜夜夜夜久久| 国产美女一区二区| 久久精品一级爱片| 国产精品一卡二卡在线观看| 精品免费日韩av| 精品一区二区在线观看| 精品国内二区三区| 国产美女精品在线| 久久久精品人体av艺术| 丁香激情综合五月| 国产精品美女www爽爽爽| 成人黄动漫网站免费app| 中文一区二区在线观看| 成人黄色小视频在线观看| 亚洲欧美怡红院| 在线一区二区三区| 日韩中文字幕麻豆| 91精品国产欧美一区二区| 日本不卡一区二区| www国产精品av| 国产不卡视频在线观看| 国产精品妹子av| 91免费看`日韩一区二区| 亚洲午夜一区二区| 欧美一二区视频| 国产成人精品三级麻豆| 国产精品另类一区| 欧美最猛黑人xxxxx猛交| 婷婷开心激情综合| 精品国产伦理网| 国产98色在线|日韩| 亚洲欧美另类小说视频| 欧美日韩mp4| 国产一区二区不卡| 中文字幕欧美一| 欧美电影在哪看比较好| 久久99久久99| 自拍偷拍亚洲激情| 欧美精品免费视频| 国产福利一区在线| 亚洲一区二区三区四区在线免费观看 | 一区二区激情小说| 欧美一区二区视频网站| 国产成人在线色| 一级女性全黄久久生活片免费| 日韩视频免费观看高清在线视频| 国产精品一区二区男女羞羞无遮挡 | 亚洲精品写真福利| 日韩一区二区精品| 成人av免费在线观看| 青青青爽久久午夜综合久久午夜 | 洋洋成人永久网站入口| 欧美tk—视频vk| 91黄视频在线| 国产成人日日夜夜| 亚洲成人av福利| 国产欧美精品区一区二区三区| 色av综合在线| 国产精品小仙女| 日韩国产高清影视| 亚洲欧美日韩在线不卡| 精品噜噜噜噜久久久久久久久试看| 不卡av免费在线观看| 日本vs亚洲vs韩国一区三区| 亚洲欧洲色图综合| 久久欧美中文字幕| 欧美日韩精品一区视频| 不卡一区二区三区四区| 久久国产精品色| 图片区小说区国产精品视频| 国产精品久久久久aaaa樱花| 精品国产一二三区|