コード例 #1
0
ファイル: DlgDialbox.cpp プロジェクト: mizutanilab/RecView
CString CDlgDialbox::GetBthComPort(CString sAddr) {
	CString sRtn = "";
	int iPort = 0;

	HKEY hKey1;
	DWORD dwNameLen1 = MAX_PATH;
	char pcName1[MAX_PATH + 1];

	LONG lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Enum\\BTHENUM", NULL, KEY_READ | KEY_ENUMERATE_SUB_KEYS, &hKey1);
	if (lResult != ERROR_SUCCESS) return sRtn;

	for (DWORD dwIndex1=0; ; dwIndex1++) {
		dwNameLen1 = MAX_PATH;
		lResult = RegEnumKeyEx( hKey1, dwIndex1, pcName1, &dwNameLen1, NULL, NULL, NULL, NULL);
		if (lResult == ERROR_NO_MORE_ITEMS) break;
		if (lResult != ERROR_SUCCESS) { continue;}
		HKEY hKey2;
		DWORD dwNameLen2 = MAX_PATH;
		char pcName2[MAX_PATH + 1];

		CString sSubKey;
		sSubKey.Format("SYSTEM\\CurrentControlSet\\Enum\\BTHENUM\\%s", pcName1);
		lResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sSubKey, NULL, KEY_READ | KEY_ENUMERATE_SUB_KEYS, &hKey2);
		if (lResult != ERROR_SUCCESS) {continue;}

		for (DWORD dwIndex2=0; ; dwIndex2++) {
			dwNameLen2 = MAX_PATH;
			lResult = RegEnumKeyEx(hKey2, dwIndex2, pcName2, &dwNameLen2, NULL, NULL, NULL, NULL);
			if (lResult == ERROR_NO_MORE_ITEMS) break;
			if (lResult != ERROR_SUCCESS) continue;

			sSubKey.Format("SYSTEM\\CurrentControlSet\\Enum\\BTHENUM\\%s\\%s", pcName1, pcName2);
			sSubKey.MakeUpper();

			if(sSubKey.Find(sAddr) < 0) continue;

			HKEY hKey3;
			char pcPort[100 + 1];
			DWORD dwLen = 100;
			if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, sSubKey + "\\Device Parameters", 0, KEY_READ, &hKey3) != ERROR_SUCCESS) continue;
			if (RegQueryValueEx(hKey3, "PortName", NULL, NULL, (LPBYTE)&pcPort, &dwLen) == ERROR_SUCCESS) {
				RegCloseKey(hKey3);
				pcPort[dwLen] = 0;
				CString sPort(pcPort);
				sPort.MakeUpper();
				if(sPort.Find("COM") >= 0) {
					sRtn = sPort;
//					sRtn += sSubKey + "\r\n" + sPort + "\r\n";
				}
			}
		}//for(dwIndex2++)
		RegCloseKey(hKey2);
    }//for(dwIndex1++)
    RegCloseKey(hKey1);
//	AfxMessageBox(sRtn + "\r\n" + sAddr);
	return sRtn;
}
コード例 #2
0
ファイル: IIS6ConfigHelper.cpp プロジェクト: UIKit0/IISxpress
bool CIIS6ConfigHelper::GetWebServerHostnameAndPort(
												IMSAdminBase* pAdminBase, 
												LPCTSTR pszMBPath, 
												CString& sHostname,
												DWORD& dwPort)												
{
	if (pAdminBase == NULL)
		return false;

	CIISMetaBaseData PortData;
	std::vector<std::wstring> saPorts;
	if (PortData.ReadData(pAdminBase, CStringW(pszMBPath), MD_SERVER_BINDINGS) == false ||
		PortData.GetAsStringVector(saPorts) == false)
		return false;
	
	for (int i = 0; i < (int) saPorts.size(); i++)
	{
		CString sPort(saPorts[i].c_str());		

		if (sPort.GetLength() == 0 || sPort[0] != ':')
			continue;		

		LPCTSTR pszToken = sPort;

		// skip the leading ':'
		pszToken++;

		// get the port
		dwPort = _ttoi(pszToken);

		// skip the number characters
		while (*pszToken != '\0' && _istdigit(*pszToken) != 0)
			pszToken++;

		// we must find the ':' here
		if (*pszToken != ':')
			continue;

		// skip the ':'
		pszToken++;

		// get the hostname
		sHostname = pszToken;

		return true;
	}

	return false;
}
コード例 #3
0
HRESULT CIIS7XMLConfigHelper::GetWebServerHostnameAndPort(IXMLDOMNode* pSite, CString& sHostname, DWORD& dwPort)
{
	if (pSite == NULL)
		return E_POINTER;

	CComPtr<IXMLDOMNode> pBindingAttr;
	HRESULT hr = pSite->selectSingleNode(
		CComBSTR(L"bindings/binding[@protocol='http']/@bindingInformation"), &pBindingAttr);

	if (hr != S_OK)
		return hr;
	
	if (pBindingAttr == NULL)
		return E_FAIL;

	CComBSTR bsBinding;
	hr = pBindingAttr->get_text(&bsBinding);
	if (hr != S_OK)
		return hr;

	CString sPort(bsBinding);

	if (sPort.GetLength() == 0 || sPort[0] != '*' || sPort[1] != ':')
		return E_FAIL;	

	LPCTSTR pszToken = sPort;

	// skip the leading '*:'
	pszToken += 2;

	// get the port
	dwPort = _ttoi(pszToken);

	// skip the number characters
	while (*pszToken != '\0' && _istdigit(*pszToken) != 0)
		pszToken++;

	// we must find the ':' here
	if (*pszToken != ':')
		return E_FAIL;

	// skip the ':'
	pszToken++;

	// get the hostname
	sHostname = pszToken;	

	return S_OK;
}
コード例 #4
0
ファイル: FSClient.cpp プロジェクト: ydarBing/Networking2.0
void FSClient::SendEndpointPort()
{
  std::string sPort("port|");
  sPort += std::to_string(config.clientUDPport);
  net->Send(sPort, serverhConn);
}