通过什么方法可以知道一台电脑是否在上网?
解决方案 »
- WINSOCKET 1.1问题请教
- 关于GetDIBits的问题?
- 关于ListBox的使用,如何得知ListBox被添加了一行或删除了一行...在线等待...
- 对话框中添加一个菜单资源后,菜单与对话框面有一个下沉的边界,如何设置菜单不下沉,与对话框相平?
- GetModuleHandle为何不能得到EXE模块的句柄
- 悬赏以百分请教如何禁用网卡,Win2K/Win98
- 谁能帮我找到VisualAssist啊?
- 求助:关于sobel算子求指纹图像方向场
- 怎样把Javascript代码写入到activex?
- VS 2008 中菜单的问题
- 菜鸟求助:如何在弹出对话框中设置并操纵列表框控件
- 为什么我每次运行程序都会出现内存错误?
{
int nCheck = AfxSocketInit();
CSocket m_Server;
HKEY hKey;
DWORD dwDial, dwDialType = REG_DWORD, dwDialSize = 4;
DWORD dwNew = 0;
BOOL bResult = true;
if ( RegOpenKeyEx ( HKEY_CURRENT_USER,
Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings",
0, KEY_SET_VALUE, &hKey) != ERROR_SUCCESS)
; // We cannot find the key. Handle this situation or just continue
if ( RegQueryValueEx( hKey, "EnableAutodial", NULL, &dwDialType,
(BYTE *) &dwDial, &dwDialSize ) != ERROR_SUCCESS )
; // We cannot find the value. Handle it. if ( dwDial ) { // We need to change the value, in order to make
// a dialup window not to show up.
if ( (nCheck = RegSetValueEx( hKey, "EnableAutodial", NULL,
dwDialType, (BYTE *) &dwNew, dwDialSize )) != ERROR_SUCCESS)
; // Failed? We shouldn't get here. You decide how to handle it
}
if ( !m_Server.Create() ) {
// m_sError = _T( "Unable to create the socket." );
bResult = false;
} // You can use www.microsoft.com in order to check whether DNS is available
// or numeric IP otherwise
else if ( !m_Server.Connect( "www.microsoft.com", 80 ) ) { // 207.46.130.150
//m_sError = _T( "Unable to connect to server" );
m_Server.Close();
bResult = false;
}
if ( dwDial ) {
if ( (nCheck = RegSetValueEx( hKey, "EnableAutodial", NULL,
dwDialType, (BYTE *) &dwDial, dwDialSize )) != ERROR_SUCCESS)
; // Failed? We shouldn't get it. You decide how to handle this.
}
RegCloseKey( hKey );
return ( bResult );
}
if (bConnected)//如果上网则为真
{
return ture;
}需包含#include "Wininet.h" 和 链接Wininet.lib