欢迎光临
我们一直在努力

怎样用vb得知系统当前是否处于internet链结状态_visualbasic教程

建站超值云服务器,限时71元/月

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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 怎样用vb得知系统当前是否处于internet链结状态_visualbasic教程
分享到: 更多 (0)