Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.visual.basic    |    MS Visual Basic discussions, NOT dot-net    |    10,840 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 8,916 of 10,840    |
|    Jack to Maarten    |
|    Re: shutdown    |
|    28 Oct 04 10:06:21    |
      From: luckyjack69@hotmail.com              thats a lot of code to shutdown a machine.              here is some code for you, this does a few things       no 1 it makes the program a service so you wont be able to see it by       pressing cntrl-alt-del       no 2 if the username and password dont match then it shuts down the computer       it is a little app i wrote to stop others using my pc       you going to have to add a few controls to a form............i let u work       that out              **************************** start of code        Option Explicit        Const EWX_LOGOFF = 0        Const EWX_SHUTDOWN = 1        Const EWX_REBOOT = 2        Const EWX_FORCE = 4        Const HWND_TOPMOST = -1        Const HWND_NOTOPMOST = -2        Const SWP_NOSIZE = &H1        Const SWP_NOMOVE = &H2        Const SWP_NOACTIVATE = &H10        Const SWP_SHOWWINDOW = &H40        Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal       hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long,       ByVal cy As Long, ByVal wFlags As Long)        Private Declare Function ExitWindowsEx Lib "User32" (ByVal uFlags As       Long, ByVal dwReserved As Long) As Long        Dim iTry As Integer        Dim lTime As Long        Dim lTimeLenth As Long        Dim strRet As String        Dim regserv        Const RSP_SIMPLE_SERVICE = 1        Const RSP_UNREGISTER_SERVICE = 0        Private Declare Function GetCurrentProcessId Lib "kernel32" () As Long        Private Declare Function RegisterServiceProcess Lib "kernel32" (ByVal       dwProcessID As Long, ByVal dwType As Long) As Long       Public Sub MakeMeService()        Dim pid As Long, reserv As Long        pid = GetCurrentProcessId()        regserv = RegisterServiceProcess(pid, RSP_SIMPLE_SERVICE)       End Sub              Public Sub UnMakeMeService()        Dim pid As Long, reserv As Long        pid = GetCurrentProcessId()        regserv = RegisterServiceProcess(pid, RSP_UNREGISTER_SERVICE)       End Sub              Private Sub cmdCancel_Click()        ShutDown       End Sub              Private Sub cmdOK_Click()        If iTry > 2 Then        ShutDown        End If        If LCase(txtUsername) = "my user name" Then        If LCase(txtPassword.Text) = "my password" Then        Unload Me        End        End If        End If        iTry = iTry + 1       End Sub              Private Sub Form_Activate()        SetWindowPos Me.hWnd, HWND_TOPMOST, 500, 0, 0, 0, SWP_NOACTIVATE Or       SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE        lTimeLenth = 2500        progTime.Max = lTimeLenth       End Sub              Private Sub Form_Load()        MakeMeService       End Sub              Private Sub Form_Unload(Cancel As Integer)        UnMakeMeService       End Sub              Private Sub tmrMain_Timer()        lTime = lTime + 1        progTime.Value = (lTimeLenth - lTime)        lblTime.Caption = (lTimeLenth - lTime)        Me.Refresh        DoEvents        If lTime = lTimeLenth Then        ShutDown        End If       End Sub              Private Sub ShutDown()        strRet = ExitWindowsEx(EWX_FORCE Or EWX_SHUTDOWN, 0)       End Sub                            **************************** end of code                                          "Maarten" |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca