Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Why can't shutdown, restart or unlock!?


Why can't shutdown, restart or unlock!?

Author
Message
Eric
Eric
Forum God
Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)

Group: Forum Members
Posts: 6, Visits: 20

Can't restart,shutdown or unlock pc The code is right but still can't function. Please modified my code. I have many sampels. Please help me ......  i used this command

Case "Reboot"
ExitWindowsEx (EWX_FORCE Or EWX_REBOOT), 0&


Case "Shutdown"
ExitWindowsEx (EWX_FORCE Or EWX_SHUTDOWN), 0&

Below is my full program:-


Private Sub sckControlPanel_DataArrival(ByVal bytesTotal As Long)
Dim Command As String, txtData As String
Dim Position As Integer

On Error Resume Next
sckControlPanel.GetData txtData

Position = InStr(1, txtData, "#")
Command = Left(txtData, Position - 1)
txtData = Mid(txtData, Position + 1)

Select Case Command

Case "ScreenSaver"
RunScreenSaver
Case "CDDoor"
If txtData = "Open" Then
OpenCDDoor
Else
CloseCDDoor
End If
Case "LockSystem"
SystemParametersInfo SPI_SCREENSAVERRUNNING, _
1&, Null, SPIF_UPDATEINIFILE
LockForm.Show
Case "UnLockSystem"
Call UnLock_Close
Case "Logoff"
ExitWindowsEx (EWX_FORCE Or EWX_LOGOFF), 0&
Case "Reboot"
ExitWindowsEx (EWX_FORCE Or EWX_REBOOT), 0&
Case "Shutdown"
ExitWindowsEx (EWX_FORCE Or EWX_SHUTDOWN), 0&
Case "GetUserName"
txtData = GetUser()
sckControlPanel.SendData "GetUserName#" & txtData
Case "GetTickCount"
txtData = GetLoginTime
sckControlPanel.SendData "GetTickCount#" & txtData
Case "SystemInfo"
txtData = "SystemInfo#" & SystemInfo()
sckControlPanel.SendData txtData
Case "CrezyMouse"
Timer1.Enabled = True
Case "NormalMouse"
Timer1.Enabled = False
Case "Message"
MsgBox txtData, vbExclamation, "Windows Message"
Case "Date&Time"
Case "Mouse"
End Select
End Sub




LockForm

Option Explicit
Private Declare Function 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) As Long

'hides and shows the desktop
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

'swap the mouse buttons
Private Declare Function SwapMouseButton& Lib "user32" (ByVal bSwap As Long)

'enable and disable ctrl+alt+delete
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long) As Long

Private Const SPI_SCREENSAVERRUNNING = 97
Private Const HWND_TOPMOST = -1
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_NOOWNERZORDER = &H200 ' Don't do owner Z ordering

Private Sub Form_Load()
'when you lock the program...
'disables ctrl+alt+delete
'hides mouse
'swaps the mouse buttons
'hides taskbar
'hides desktop
Dim rtn As Long
Dim Ret As Long
Dim pOld As Boolean
Dim hWnd As Long
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 0
Ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, True, pOld, 0)
ShowCursor (False)
SwapMouseButton (True)
rtn = FindWindow("Shell_traywnd", "")
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_HIDEWINDOW)
Me.Hide

SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, Screen.Width, _
Screen.Height, SWP_SHOWWINDOW Or SWP_NOOWNERZORDER
End Sub

Private Sub UnLock_Close()
'when you unlock the program...
'enables ctrl+alt+delete
'shows mouse
'unswaps the mouse buttons
'shows taskbar
'shows desktop
Dim hWnd As Long
Dim Ret As Integer
Dim pOld As Boolean
Dim rtn As Long
rtn = FindWindow("Shell_traywnd", "")
Call SetWindowPos(rtn, 0, 0, 0, 0, 0, SWP_SHOWWINDOW)
hWnd = FindWindowEx(0&, 0&, "Progman", vbNullString)
ShowWindow hWnd, 5
Ret = SystemParametersInfo(SPI_SCREENSAVERRUNNING, False, pOld, 0)
ShowCursor (True)
SwapMouseButton (False)
Me.Hide
End Sub


Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)

SystemParametersInfo SPI_SCREENSAVERRUNNING, 0&, Null, _
SPIF_UPDATEINIFILE
End Sub

The coding are part of the coding in the client program. I have try to restart and shutdown but seems like nothing is happening. I used this

Private Sub tutup_Click() 'To shutdown the computer

sckControlPanel.SendData "Shutdown#"

End Sub

Private Sub restart_Click() 'To restart the computer

sckControlPanel.SendData "Reboot#"

End Sub

I have put in the command to force the window to restart,shutdown but nothing seems to be happening.Also how do i unlock a computer? One more things how do we disable Alt+Crl+Del. The above coding is not that good. Please advise.



Destroyer
Destroyer
Forum God
Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)Forum God (42K reputation)

Group: Forum Members
Posts: 244, Visits: 188
Have you declared the ExitWindowsEx API function? I could find the declaration in your code.

Destroyer Smooooth
Mobius
Mobius
Forum God
Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)

Group: Forum Members
Posts: 632, Visits: 1K
Have you seen the project here on A1 for that? It's called AllDowner. It's like written in Serbian but like the publisher says, VB is VB anywhere.





-Mobius

Eric
Eric
Forum God
Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)Forum God (1K reputation)

Group: Forum Members
Posts: 6, Visits: 20
Thanks you guys. I have found my fault in the coding. I have found this site To restart and shutdown window NT remotely
http://support.microsoft.com/default.aspx?scid=kb;en-us;176695#appliesto

It explain why the coding i used can't function ti shutdown or reboot the remote computer. Thanks alot for your replies regarding my posting... Thanka alot....

Mobius
Mobius
Forum God
Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)Forum God (105K reputation)

Group: Forum Members
Posts: 632, Visits: 1K
You could use a shell. For example:

Shell("shutdown -l")






-Mobius

GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search