Visual Basic - como cerrar ventanas desde el Visual Basic

Life is soft - evento anual de software empresarial
 
Vista:

como cerrar ventanas desde el Visual Basic

Publicado por Maria Cecilia López Saavedra (4 intervenciones) el 02/01/2001 00:00:00
Hola espero que se encuentren bien y que me puedan ayudar, saben estoy haciendo un sistema que apaga la maquina desde el visual vasic pero no se como hacerle para que cuando salga de mi sistema apage la maquina y dcierre todas las ventanas que estubieran abiertas en windoos bueno lo de apagar la maquina ya lo hace pero cuando prendo la maquina se encuentran abiertas todas las ventanas que estaban abiertas antes de apagar la maquina bueno por su atención muchas gracias y espero que puedan ayudarme.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil

RE:como cerrar ventanas desde el Visual Basic

Publicado por Joan Fabregas (101 intervenciones) el 02/01/2001 00:00:00
Puedes Probar lo siguiente:

Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Const WM_CLOSE = &H10

Const GW_CHILD = 5
Const GW_HWNDFIRST = 0
Const GW_HWNDLAST = 1
Const GW_HWNDNEXT = 2
Const GW_HWNDPREV = 3
Const GW_OWNER = 4

Private Sub CloseAll()
Dim sTitle As String
Dim myHwnd
Dim lReturn As Long

myHwnd = GetWindow(Me.hwnd, GW_OWNER)

Do While myHwnd <> 0
DoEvents
sTitle = GetWinCaption(myHwnd)

If sTitle <> "" Then
lReturn = PostMessage(myhwnd, WM_CLOSE, 0, 0)
If lReturn = 0 Then
msgbox "Error cerrando la Ventana " & sTitle
End If
End If
´get the next window
myHwnd = GetWindow(myHwnd, GW_HWNDNEXT)
Loop
End Sub

Public Function GetWinCaption(hwnd) As String
Dim iTextLength As Integer
Dim sTitle As String
iTextLength = GetWindowTextLength(hwnd)
sTitle = String(iTextLength, 0)
GetWindowText hwnd, sTitle, iTextLength + 1
GetWinCaption = sTitle
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar