Visual Basic - ESCRIBIR EN PANTALLA DEL MSDOS

Life is soft - evento anual de software empresarial
 
Vista:

ESCRIBIR EN PANTALLA DEL MSDOS

Publicado por ChaRLinux (25 intervenciones) el 02/02/2005 21:32:02
ME GUSTARIA QUE ME GUIARAN COMO PUEDO ESCRIBIR DESDE UN FORMULARIO DE VISUAL BASIC DIRECTAMENTE EN LA PANTALLA DEL MS DOS COMO CON EL USO DEL SEND KEY GRACIAS
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

Escribir en Consola I

Publicado por Benjo (679 intervenciones) el 03/02/2005 02:23:49
En realidad no he visto que se pudiera escribir en la consola con SendKeys, pero para ello bien podrías usar la API

WriteConsole de kernel32
'En un Módulo Bas
Declare Function AllocConsole Lib "kernel32" () As Long
Declare Function FreeConsole Lib "kernel32" () As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Declare Function GetStdHandle Lib "kernel32" (ByVal nStdHandle As Long) As Long
Declare Function WriteConsole Lib "kernel32" Alias "WriteConsoleA" (ByVal hConsoleOutput As Long, lpBuffer As Any, ByVal nNumberOfCharsToWrite As Long, lpNumberOfCharsWritten As Long, lpReserved As Any) As Long
Declare Function SetConsoleCtrlHandler Lib "kernel32" (ByVal HandlerRoutine As Long, ByVal Add As Long) As Long
Public Const STD_OUTPUT_HANDLE = -11&
Public hConsole As Long
Public Function ConsoleHandler(ByVal CtrlType As Long) As Long
ConsoleHandler = 1
End Function

'En el Formulario tres ommand y un textBox
Public objConsole As New clsConsole
Private Sub cbCloseConsole_Click()
objConsole.CloseConsole
End Sub
Private Sub cbConsoleOutput_Click()
objConsole.SendText (tbConsole.Text)
End Sub
Private Sub cbOpenConsole_Click()
If Not objConsole.OpenConsole Then
MsgBox "Couldn't allocate console"
End If
End Sub
'------> En el siguiente la Classe
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

Escribir en Consola II

Publicado por Benjo (679 intervenciones) el 03/02/2005 02:25:02
'Crear una clase llamada clsConsole

Public Function CloseConsole() As Boolean
If CloseHandle(hConsole) <> 0 Then hConsole = 0
FreeConsole
End Function
Public Function OpenConsole() As Boolean
If AllocConsole() Then
hConsole = GetStdHandle(STD_OUTPUT_HANDLE)
If hConsole = 0 Then
FreeConsole
Else
SetConsoleCtrlHandler AddressOf ConsoleHandler, True
OpenConsole = True
End If
End If
End Function
Public Function SendText(sText As String) As Boolean
Dim sOut As String, cWritten As Long
sOut = sText & vbCrLf
SendText = WriteConsole(hConsole, ByVal sOut, Len(sOut), cWritten, ByVal 0&)
End Function
Private Sub Class_Terminate()
If hConsole <> 0 Then
CloseHandle hConsole
FreeConsole
End If
End Sub
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