Private Sub Form_Load() If IsConnected = TRUE Then MsgBox (“您已经连通了Internet!”) End If If IsConnected = FALSE Then MsgBox (“您还没有连通 Internet!”) End If End Sub Option Explicit /*有关的API声明和定义*/ Public Declare Function RasEnumConnections Lib “RasApi32.dll” Alias “RasEnumConnectionsA” (lpRasCon As Any, lpcb As Long, lpcConnections As Long) As Long Public Declare Function RasGetConnectStatus Lib “RasApi32.dll” Alias “RasGetConnectStatusA” (ByVal hRasCon As Long, lpStatus As Any) As Long /*常数和变量的设定*/ Public Const RAS95_MaxEntryName = 256 Public Const RAS95_MaxDeviceType = 16 Public Const RAS95_MaxDeviceName = 32 Public Type RASCONN95 dwSize As Long hRasCon As Long szEntryName(RAS95_MaxEntryName) As Byte szDeviceType(RAS95_MaxDeviceType) As Byte szDeviceName(RAS95_MaxDeviceName) As Byte End Type Public Type RASCONNSTATUS95 dwSize As Long RasConnState As Long dwError As Long szDeviceType(RAS95_MaxDeviceType) As Byte szDeviceName(RAS95_MaxDeviceName) As Byte End Type /*函数IsConnected返回连通的状态,如果为True则表示已连通*/ Public Function IsConnected() As Boolean Dim TRasCon(255) As RASCONN95 Dim lg As Long Dim lpcon As Long Dim RetVal As Long Dim Tstatus As RASCONNSTATUS95 TRasCon(0).dwSize = 412 lg = 256 * TRasCon(0).dwSize RetVal = RasEnumConnections(TRasCon(0), lg, lpcon) If RetVal <> 0 Then MsgBox “错误” Exit Function End If Tstatus.dwSize = 160 RetVal = RasGetConnectStatus(TRasCon(0) .hRasCon,Tstatus) If Tstatus.RasConnState = &H2000 Then IsConnected = TRUE Else IsConnected = FALSE End If End Function |
Option Explicit /*有关的API声明*/ Private Declare Function RegOpenKeyEx Lib “advapi32” Alias “RegOpenKeyExA” (ByVal hKey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long Private Declare Function RegQueryvalueEx Lib “advapi32” Alias “RegQueryvalueExA” (ByVal hKey As Long, ByVal lpvalueName As String, ByVal lpReserved As Long, ByRef lpType As Long, ByVal szData As String, ByRef lpcbData As Long) As Long Private Declare Function RegCloseKey Lib “advapi32”(ByVal hKey As Long) As Long /*常数的设定*/ Const HKEY_CURRENT_USER = &H80000001 Const ERROR_SUCCESS = 0 在命令按钮(cmdCallConnect)中加入如下代码: Private Sub cmdCallConnect_Click() /*启动默认拨号连接*/ Shell “rundll rnaui.dll,RnaDial” + GetConnect, vbNormalFocus End Sub /*取得连接的函数(GetConnect)*/ Public Function GetConnect() As String Dim hKey As Long Dim SubKey As String /*主键*/ hKey = HKEY_CURRENT_USER /*子键*/ SubKey = “RemoteAccess” /*取得默认连接名*/ GetConnect=GetRegvalue(hKey,SubKey, “Default”) End Function /*取得注册的函数(GetRegvalue)*/ Public Function GetRegvalue(hKey As Long,lpszSubKey As String,szKey As String) As Variant On Error GoTo ErrorRoutineErr: Dim phkResult As Long Dim lResult As Long Dim szBuffer As String Dim lBuffSize As Long /*创建缓冲区*/ szBuffer = Space(255) lBuffSize = Len(szBuffer) /*打开注册键*/ RegOpenKeyEx hKey, lpszSubKey, 0, 1,phkResult /*取得查询结果*/ lResult = RegQueryvalueEx(phkResult, szKey, 0, 0, szBuffer, lBuffSize) /*关闭注册键*/ RegCloseKey phkResult /*返回结果*/ If lResult = ERROR_SUCCESS Then GetRegvalue = Left(szBuffer, lBuffSize - 1) Else GetRegvalue =“” End If Exit Function /*意外处理*/ ErrorRoutineErr: GetRegvalue =“” End Function |
MAPIMessage1.Fetch Form1.Caption=MAPIMessage1.MsgCount MAPIMessage1.MsgIndex=CINT(Indexno.text) Subject.Text = MAPIMessage1.MsgNoteText Content.Text = MAPIMessage1.MsgSubject |
MAPISession1.SignOn MAPIMessage1.SessionID=MAPISession1.SessionID sgBox “Your ID is” + Str (MAPISession1.SessionID) |
MAPIMessage1.Compose MAPIMessage1.RecipDisplayName = Addr.text MAPIMessage1.AddressResolveUI = TRUE MAPIMessage1.MsgSubject = Subject.text MAPIMessage1.MsgNoteText = Content.text MAPIMessage1.Send MsgBox “您发送成功啦!” |
/*载入Form*/ Private Sub Form_Load() /*程序装入后进入IE设定的起始页*/ WebBrowser1.GoHome End Sub /*改变Form尺寸*/ Private Sub Form_Resize() /*改变窗口大小后同时改变控件的大小*/ WebBrowser1.Width = Form1.ScaleWidth WebBrowser1.Height = Form1.ScaleHeight - 900 Label1.Width = Form1.ScaleWidth Label1.Top = Form1.ScaleHeight - 300 End Sub Private Sub BackButton_Click() /*返回上一个页面*/ WebBrowser1.GoBack End Sub Private Sub ForwardButton_Click() /*进入下一个页面*/ WebBrowser1.GoForward End Sub Private Sub GoButton_Click() /*浏览输入的页面*/ WebBrowser1.Navigate (Text1.Text) End Sub Private Sub StopButton_Click() /*停止浏览*/ WebBrowser1.Stop End Sub Private Sub Text1_KeyPress(KeyAscii As Integer) /*输入地址后进行浏览*/ If KeyAscii = 13 Then WebBrowser1.Navigate (Text1.Text) End If End Sub Private Sub WebBrowser1_BeforeNavigate(ByVal URL As String, ByVal Flags As Long, ByVal TargetFrameName As String, PostData As Variant, ByVal Headers As String, Cancel As Boolean) /*将当前显示的页面的URL地址显示在Text1上*/ Text1.Text = URL End Sub Private Sub WebBrowser1_StatusTextChange(ByVal Text As String) /*Label1显示当前页面装入情况*/ Label1.Caption = Text End Sub |