怎样用VB得知系统当前是否处于internet链结状态
敬业的IT人
互联网
佚名
2008-1-3 18:02:27
声明以下函数变量常量:
DeclareFunctionRegCloseKeyLib"advapi32.dll"(ByValhKeyAsLong)AsLong
DeclareFunctionRegQueryValueExLib"advapi32.dll"Alias"RegQueryValueExA"(ByValhKeyAsLong,ByVallpValueNameAsString,ByVallpReservedAsLong,lpTypeAsLong,lpDataAsAny,lpcbDataAsLong)AsLong
DeclareFunctionRegOpenKeyLib"advapi32.dll"Alias"RegOpenKeyA"(ByValhKeyAsLong,ByVallpSubKeyAsString,phkResultAsLong)AsLong
PublicConstERROR_SUCCESS=0&
PublicConstAPINULL=0&
PublicConstHKEY_LOCAL_MACHINE=&H80000002
PublicReturnCodeAsLong
代码:
PublicFunctionActiveConnection()AsBoolean
DimhKeyAsLong
DimlpSubKeyAsString
DimphkResultAsLong
DimlpValueNameAsString
DimlpReservedAsLong
DimlpTypeAsLong
DimlpDataAsLong
DimlpcbDataAsLong
ActiveConnection=False
lpSubKey="System\CurrentControlSet\Services\RemoteAccess"
ReturnCode=RegOpenKey(HKEY_LOCAL_MACHINE,lpSubKey,phkResult)
IfReturnCode=ERROR_SUCCESSThen
hKey=phkResult
lpValueName="RemoteConnection"
lpReserved=APINULL
lpType=APINULL
lpData=APINULL
lpcbData=APINULL
ReturnCode=RegQueryValueEx(hKey,lpValueName,lpReserved,lpType,lpData,lpcbData)
lpcbData=Len(lpData)
ReturnCode=ReturnCode=RegQueryValueEx(hKey,lpValueName,lpReserved,lpType,lpData,lpcbData)
IfReturnCode=ERROR_SUCCESSThen
IflpData=0Then
ActiveConnection=False
Else
ActiveConnection=True
EndIf
EndIf
RegCloseKey(hKey)
EndIf
EndFunction
下面是使用以上代码的例子:
IfActiveConnection=Truethen
CallMsgBox("现在处于链结状态。",vbInformation)
Else
CallMsgBox("现在处于断开状态。",vbInformation)
EndIf->
DeclareFunctionRegCloseKeyLib"advapi32.dll"(ByValhKeyAsLong)AsLong
DeclareFunctionRegQueryValueExLib"advapi32.dll"Alias"RegQueryValueExA"(ByValhKeyAsLong,ByVallpValueNameAsString,ByVallpReservedAsLong,lpTypeAsLong,lpDataAsAny,lpcbDataAsLong)AsLong
DeclareFunctionRegOpenKeyLib"advapi32.dll"Alias"RegOpenKeyA"(ByValhKeyAsLong,ByVallpSubKeyAsString,phkResultAsLong)AsLong
PublicConstERROR_SUCCESS=0&
PublicConstAPINULL=0&
PublicConstHKEY_LOCAL_MACHINE=&H80000002
PublicReturnCodeAsLong
代码:
PublicFunctionActiveConnection()AsBoolean
DimhKeyAsLong
DimlpSubKeyAsString
DimphkResultAsLong
DimlpValueNameAsString
DimlpReservedAsLong
DimlpTypeAsLong
DimlpDataAsLong
DimlpcbDataAsLong
ActiveConnection=False
lpSubKey="System\CurrentControlSet\Services\RemoteAccess"
ReturnCode=RegOpenKey(HKEY_LOCAL_MACHINE,lpSubKey,phkResult)
IfReturnCode=ERROR_SUCCESSThen
hKey=phkResult
lpValueName="RemoteConnection"
lpReserved=APINULL
lpType=APINULL
lpData=APINULL
lpcbData=APINULL
ReturnCode=RegQueryValueEx(hKey,lpValueName,lpReserved,lpType,lpData,lpcbData)
lpcbData=Len(lpData)
ReturnCode=ReturnCode=RegQueryValueEx(hKey,lpValueName,lpReserved,lpType,lpData,lpcbData)
IfReturnCode=ERROR_SUCCESSThen
IflpData=0Then
ActiveConnection=False
Else
ActiveConnection=True
EndIf
EndIf
RegCloseKey(hKey)
EndIf
EndFunction
下面是使用以上代码的例子:
IfActiveConnection=Truethen
CallMsgBox("现在处于链结状态。",vbInformation)
Else
CallMsgBox("现在处于断开状态。",vbInformation)
EndIf->
- 最新文章
- 制作自己的网络搜索软件[01-03]
- Whois示例程序[01-03]
- 怎样接收电子邮件(POP3协议简介)[01-03]
- 在桌面上建立一个Internet快捷键[01-03]
- SetFormName=Nothing[01-03]
- 得知目前Mouse所指的MenuItem是哪一个[01-03]
- 相关文章
- 在桌面上建立一个Internet快捷键[01-03]
- 维护InternetTransferControl之User..[01-03]
- XFocus Windows Internet服务器安全配置[01-03]
- Win 2003配置DNS的Internet访问[01-03]
- 在Win 2003中重置Internet协议[01-03]
- 在Win2003配置DNS的Internet访问[01-03]
