怎样用VB得知系统当前是否处于internet链结状态

2018-06-17 17:13:16来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

声明以下函数变量常量:
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->

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:VB中如何实现文本查找功能

下一篇:VisualBasic编程访问WMI对象