home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{BDC217C8-ED16-11CD-956C-0000C04E4C0A}#1.1#0"; "TabCtl32.OCX" Begin VB.Form frmAPICalls BorderStyle = 1 'Fixed Single Caption = "API Demonstration" ClientHeight = 4380 ClientLeft = 4920 ClientTop = 4605 ClientWidth = 7110 Icon = "frmAPICalls.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 4380 ScaleWidth = 7110 StartUpPosition = 2 'CenterScreen Begin TabDlg.SSTab TabAPICalls Height = 3975 Left = 120 TabIndex = 0 Top = 240 Width = 6855 _ExtentX = 12091 _ExtentY = 7011 _Version = 393216 Tabs = 4 Tab = 3 TabsPerRow = 2 TabHeight = 520 TabCaption(0) = "PING" TabPicture(0) = "frmAPICalls.frx":0442 Tab(0).ControlEnabled= 0 'False Tab(0).Control(0)= "cmdPingExecute" Tab(0).Control(1)= "txtSystemName" Tab(0).Control(2)= "lblSystemName" Tab(0).Control(3)= "lblPingInstructions" Tab(0).ControlCount= 4 TabCaption(1) = "Reboot/Shutdown" TabPicture(1) = "frmAPICalls.frx":045E Tab(1).ControlEnabled= 0 'False Tab(1).Control(0)= "cmdShutdown" Tab(1).Control(1)= "cmdReboot" Tab(1).Control(2)= "lblRebootInstructions" Tab(1).ControlCount= 3 TabCaption(2) = "User/Computer Name" TabPicture(2) = "frmAPICalls.frx":047A Tab(2).ControlEnabled= 0 'False Tab(2).Control(0)= "cmdComputerName" Tab(2).Control(1)= "cmdUserName" Tab(2).Control(2)= "lblUserComputerName" Tab(2).ControlCount= 3 TabCaption(3) = "NT Services Manager" TabPicture(3) = "frmAPICalls.frx":0496 Tab(3).ControlEnabled= -1 'True Tab(3).Control(0)= "lblNTServices" Tab(3).Control(0).Enabled= 0 'False Tab(3).Control(1)= "lblComputerName" Tab(3).Control(1).Enabled= 0 'False Tab(3).Control(2)= "lblServiceName" Tab(3).Control(2).Enabled= 0 'False Tab(3).Control(3)= "txtComputerName" Tab(3).Control(3).Enabled= 0 'False Tab(3).Control(4)= "txtServiceName" Tab(3).Control(4).Enabled= 0 'False Tab(3).Control(5)= "fraService" Tab(3).Control(5).Enabled= 0 'False Tab(3).Control(6)= "cmdService" Tab(3).Control(6).Enabled= 0 'False Tab(3).ControlCount= 7 Begin VB.CommandButton cmdService Caption = "Execute Command" Enabled = 0 'False Height = 255 Left = 2040 TabIndex = 7 Top = 3480 Width = 1575 End Begin VB.Frame fraService Caption = "Command Choices" Height = 1335 Left = 3960 TabIndex = 21 Top = 2520 Width = 2655 Begin VB.OptionButton optService Caption = "STOP SERVICE" Height = 255 Index = 3 Left = 120 TabIndex = 6 Top = 960 Width = 1575 End Begin VB.OptionButton optService Caption = "PAUSE SERVICE" Height = 255 Index = 2 Left = 120 TabIndex = 5 Top = 720 Width = 1575 End Begin VB.OptionButton optService Caption = "START SERVICE" Height = 255 Index = 1 Left = 120 TabIndex = 4 Top = 480 Width = 1575 End Begin VB.OptionButton optService Caption = "GET STATUS" Height = 255 Index = 0 Left = 120 TabIndex = 3 Top = 240 Width = 1575 End End Begin VB.TextBox txtServiceName Height = 285 Left = 1680 TabIndex = 2 Top = 3000 Width = 2175 End Begin VB.TextBox txtComputerName Height = 285 Left = 1680 TabIndex = 1 Top = 2640 Width = 2175 End Begin VB.CommandButton cmdComputerName Caption = "COMPUTER" Height = 375 Left = -71160 TabIndex = 17 Top = 3060 Width = 1215 End Begin VB.CommandButton cmdUserName Caption = "USER" Height = 375 Left = -73560 TabIndex = 16 Top = 3060 Width = 1215 End Begin VB.CommandButton cmdShutdown Caption = "SHUTDOWN" Height = 375 Left = -71160 TabIndex = 14 Top = 3060 Width = 1215 End Begin VB.CommandButton cmdReboot Caption = "REBOOT" Height = 375 Left = -73560 TabIndex = 13 Top = 3060 Width = 1215 End Begin VB.CommandButton cmdPingExecute Caption = "PING" Default = -1 'True Height = 375 Left = -72120 TabIndex = 12 Top = 3420 Width = 975 End Begin VB.TextBox txtSystemName Height = 285 Left = -72600 TabIndex = 10 Text = "www.yahoo.com" Top = 2700 Width = 3855 End Begin VB.Label lblServiceName Caption = "Service Name:" Height = 255 Left = 240 TabIndex = 20 Top = 3000 Width = 1215 End Begin VB.Label lblComputerName Caption = "Computer Name:" Height = 255 Left = 240 TabIndex = 19 Top = 2640 Width = 1215 End Begin VB.Label lblNTServices BackColor = &H00E0E0E0& Height = 1575 Left = 120 TabIndex = 18 Top = 960 Width = 6495 End Begin VB.Label lblUserComputerName BackColor = &H00E0E0E0& Height = 1575 Left = -74880 TabIndex = 15 Top = 900 Width = 6495 End Begin VB.Label lblRebootInstructions BackColor = &H00E0E0E0& Height = 1575 Left = -74880 TabIndex = 11 Top = 900 Width = 6495 End Begin VB.Label lblSystemName Caption = "Enter NetBIOS, DNS or IP:" Height = 255 Left = -74880 TabIndex = 9 Top = 2700 Width = 2055 End Begin VB.Label lblPingInstructions BackColor = &H00E0E0E0& Height = 1575 Left = -74880 TabIndex = 8 Top = 900 Width = 6495 End End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuExit Caption = "E&xit" End End Attribute VB_Name = "frmAPICalls" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Private Sub cmdComputerName_Click() MsgBox "The computer name is: " & ComputerName, vbOKOnly, "GETCOMPUTERNAME API" End Sub Private Sub cmdPingExecute_Click() 'Disable Command Button to prevent multiple clicks by user cmdPingExecute.Enabled = False 'Actual PING code calls Dim PING As ICMP, Result As Boolean Set PING = New ICMP Result = PING.DoPing(txtSystemName.Text) MsgBox "IP Address: " & PING.LastIP, vbInformation, "PING Results" 'Re-enable Command Button cmdPingExecute.Enabled = True End Sub Private Sub cmdReboot_Click() '-----Must adjust security token for Windows NT Systems----- If glngWhichWindows32 = mlngWindowsNT Then AdjustToken ExitWindowsEx EWX_REBOOT, 0 Unload Me End Sub Private Sub cmdService_Click() Dim x As Integer '-----I know there is an easier way to determine the----- '-----option button that is clicked - I'm having a brain lapse----- For x = 0 To optService.Count - 1 If optService.Item(x) = True Then Exit For End If Next x Select Case x Case 0 'Get Service Status MsgBox "Current Status: " & ServiceStatus(txtComputerName.Text, txtServiceName.Text), vbOKOnly, "SERVICE STATUS" Case 1 'Start Service ServiceStart txtComputerName.Text, txtServiceName.Text Case 2 'Pause Service ServicePause txtComputerName.Text, txtServiceName.Text Case 3 'Stop Service ServiceStop txtComputerName.Text, txtServiceName.Text End Select End Sub Private Sub cmdShutdown_Click() '-----Must adjust security token for Windows NT Systems----- If glngWhichWindows32 = mlngWindowsNT Then AdjustToken ExitWindowsEx EWX_SHUTDOWN, 0 Unload Me End Sub Private Sub cmdUserName_Click() MsgBox "The logged on user is: " & UserName, vbOKOnly, "GETUSERNAME API" End Sub Private Sub Form_Load() '-----Set the Instructions for each tab----- lblPingInstructions.Caption = "PING(Packet InterNet Groper0) allows the user to determine if a remote system is online. Enter a NetBIOS computer name(if you are on a network) like MYSERVERNAME or a DNS Name(if you are on the Internet) like www.yahoo.com OR you can enter the IP address of the computer 141.10.3.132 for example." & vbCrLf & vbCrLf & "This program will return the IP address if the system is online or an error message such as 'Unable to Locate Host' if offline." lblRebootInstructions.Caption = "This tab allows you to Reboot or Shutdown your computer using a single button click. You will notice a lot of code is used to adjust security token privileges for Windows NT. If you are using only Windows 95/98 that code portion can be removed. Using the complete module listed here, this program will work for Windows NT and Windows 95/98." & vbCrLf & vbCrLf & "WARNING: Save ALL data before using these commands!!!!" lblUserComputerName.Caption = "These buttons will use the GetComputerName and the GetUserName API calls. For Windows 95/98 systems without a logon prompt, the GetUserName API may be blank. For Windows 95/98 systems without a network connection, the GetComputerName API may be blank." lblNTServices.Caption = "This section will allow you to get the current status of NT SERVICES and START/STOP/PAUSE them. Keep in mind that you must have a user account with privileges to change the status of services." & vbCrLf & vbCrLf & "A full-version is available that lists the services for you. E-mail Shane.Hage@Roche.com to request it." & vbCrLf & "For the LOCAL MACHINE, DO NOT enter any Computer Name in." '-----Determine the version of Windows running----- Dim lngVersion As Long lngVersion = GetVersion() If ((lngVersion And &H80000000) = 0) Then glngWhichWindows32 = mlngWindowsNT Else glngWhichWindows32 = mlngWindows95 End If End Sub Private Sub mnuExit_Click() End End Sub Private Sub optService_Click(Index As Integer) cmdService.Enabled = True End Sub