Parent Directory | Revision Log
+ more switches and arguments for command-line version
1 | Attribute VB_Name = "Module_Main" |
2 | Option Explicit |
3 | |
4 | ' see: How To Obtain the IP Address Assigned to a RAS Client |
5 | ' http://support.microsoft.com/default.aspx?scid=kb;en-us;160622 |
6 | |
7 | ' see: RasGetProjectionInfo |
8 | ' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcecomm5/html/wce50lrfRasGetProjectionInfo.asp |
9 | |
10 | ' http://home.iprimus.com.au/billmcc/PlatformVB/dun/rasenumentries.htm |
11 | ' http://home.iprimus.com.au/billmcc/PlatformVB/dun/raserrorhandler.htm |
12 | ' http://www.mentalis.org/apilist/RasEnumEntries.shtml |
13 | |
14 | ' http://www.activevb.de/tipps/tipkat/kat1.html |
15 | ' http://www.activevb.de/rubriken/apikatalog/deklarationen/rasenumentries.html |
16 | ' http://www.dotnet247.com/247reference/msgs/18/93960.aspx |
17 | |
18 | Public RasEntries As New Collection |
19 | |
20 | Sub Main() |
21 | |
22 | Dim cmdline As New CommandLine |
23 | Dim conName As String |
24 | Dim script_name As String, script_args As String |
25 | Dim rasItem As RasEntryData |
26 | Dim success As Boolean |
27 | |
28 | ReadRasEntries |
29 | cmdline.parse |
30 | |
31 | If cmdline.hasSwitch("gui") Then |
32 | Form_Main.Show |
33 | Else |
34 | |
35 | If cmdline.hasSwitch("dial") Then |
36 | |
37 | ' dial command |
38 | conName = cmdline.getArgument("dial") |
39 | On Error Resume Next |
40 | Set rasItem = RasEntries(conName) |
41 | If Err.Number = 0 Then |
42 | success = RasConnect(rasItem.entryname, rasItem.PhonebookPath) |
43 | Else |
44 | MsgBox "Unkown RAS-Connection """ & conName & """." |
45 | End If |
46 | On Error GoTo 0 |
47 | |
48 | ElseIf cmdline.hasSwitch("hangup") Then |
49 | ' hangup command |
50 | conName = cmdline.getArgument("hangup") |
51 | success = RasDisconnect(conName) |
52 | 'MsgBox success |
53 | |
54 | End If |
55 | |
56 | ' run script |
57 | If cmdline.hasSwitch("script") And success = True Then |
58 | script_name = cmdline.getArgument("script") |
59 | If script_name <> "" Then |
60 | script_args = Chr(34) & DetermineClientIP() & Chr(34) & " " & Chr(34) & DetermineServerIP & Chr(34) |
61 | Shell App.Path & "\" & script_name & " " & script_args, vbHide |
62 | End If |
63 | End If |
64 | |
65 | End If |
66 | |
67 | End Sub |
68 | |
69 | Private Sub ReadRasEntries() |
70 | |
71 | Dim myEntries() As VBRasEntryName |
72 | Dim lngCount As Long |
73 | Dim rasItem As RasEntryData |
74 | |
75 | lngCount = VBRasGetAllEntries(myEntries) |
76 | |
77 | 'MsgBox lngCount |
78 | Dim i As Integer |
79 | Dim curEntry As VBRasEntryName |
80 | For i = 0 To lngCount - 1 |
81 | curEntry = myEntries(i) |
82 | |
83 | Set rasItem = New RasEntryData |
84 | rasItem.entryname = curEntry.entryname |
85 | rasItem.PhonebookPath = curEntry.PhonebookPath |
86 | rasItem.Win2000_SystemPhonebook = curEntry.Win2000_SystemPhonebook |
87 | |
88 | RasEntries.add rasItem, rasItem.entryname |
89 | Next i |
90 | |
91 | End Sub |
MailToCvsAdmin">MailToCvsAdmin | ViewVC Help |
Powered by ViewVC 1.1.26 |