1.建立新模块 public const ERROR-SUCCESS= 0& public const APINULL= 0& public const HKEY-LOCAL-MACHINE= &H80000002 public ReturnCode as long 声明API函数 RegCloseKey() RegQueryValueEx() 自定义函数 public function ActiveConnection() as boolean dim hKey as long dim lpSubKey as string dim lpReserved as long dim lpType as long dim lpData as long dim lpcbData as long ActiveConnection=False lpSubKey="System\CurrentControlSet\Services\RemoteAccess" ReturnCode=RegOpenKey(HKEY-LOCAL-MACHINE,lpSubKey,phkResult) if ReturnCode=ERROR-SUCCESS then hKey=phkResult lpValueName="Remote Connection" lpReserved=APINULL lpType=APINULL lpData=APINULL lpcbData=APINULL ReturnCode=RegQueryValueEx(hKey,lpValueName,lpReserved,lpType,ByVal lpData,lpcba ta) lpcbData=Len(lpData) ReturnCode=RegQueryValueEx(hKey,lpValueName,lpReserved,lpType,ByVal lpData,lpcba ta) if ReturnCode=ERROR-SUCCESS then if lpData=0 then ActiveConnection=false else ActiveConnection=True end if end if RegCloseKey(hKey) end if end funtion 2.新建窗体 priate sub Command1-click() if ActiveConnection=True then msgbox "OK!" else msgbox "ERROR!" end sub
Copyright @ 2007-2012 敏韬网(敏而好学,文韬武略--MinTao.Net)(学习笔记) Inc All Rights Reserved. 闵涛 E_mail:admin@mintao.net(欢迎提供学习资源)
鄂公网安备 42011102001154号
站长:MinTao ICP备案号:鄂ICP备11006601号-18