1. - Averiguar información básica de un equipo:
Código:
'APIS
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Sub Command1_Click()
txtUser.Text = NombreUsuario
txtWin.Text = WinDir
txtPC.Text = NombreEquipo
End Sub
Function WinDir() As String
Dim Contenido As String
Contenido = String(255, 0)
W = GetWindowsDirectory(Contenido, Len(Contenido))
WinDir = Contenido
End Function
Function NombreUsuario() As String
Dim Contenido As String
Contenido = String(255, 0)
W = GetUserName(Contenido, Len(Contenido))
NombreUsuario = Contenido
End Function
Function NombreEquipo() As String
Dim Contenido As String
Contenido = String(255, 0)
W = GetComputerName(Contenido, Len(Contenido))
NombreEquipo = Contenido
End Function
2. - Minimizar ventanas:
Código:
' APIS
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
' Constantes.
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LWIN = &H5B
Private Sub Command1_Click()
Call keybd_event(VK_LWIN, 0, 0, 0)
Call keybd_event(77, 0, 0, 0)
Call keybd_event(VK_LWIN, 0, KEYEVENTF_KEYUP, 0)
End Sub
3. - Capturar pantalla:
Código:
' APIS
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Sub Command1_Click()
Call keybd_event(44, 0, 0&, 0&)
DoEvents
SavePicture Clipboard.GetData, App.Path & "\Captura.bmp"
End Sub