Not a Member Yet,
Click here to Register
How do you like the new design?






ID: 393
Viewed: 3050
Added: Aug 19, 2002
Version:
Snippet uploaded by: snippet
Written By: Unknown
Demo: Sorry, no demo



User Rated at: 0 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

read from console app

' See KB Article : Q171654

Highlight all by clicking in box
<!---Declaration--->
'2. You have wrong declaration of ReadConsoleOutputCharacter Function.

'Use this declaration:

Declare Function ReadConsoleOutputCharacter Lib "kernel32" _
Alias "ReadConsoleOutputCharacterA" (ByVal hConsoleOutput As Long, _
ByVal lpCharacter As String, ByVal nLength As Long, _
ByVal dwReadX As Integer, ByVal dwReadY As Integer, _
lpNumberOfCharsRead As Long) As Long

'3. The first character position In Console Screen Buffer Is (0,0).


Type COORD
X As Integer
Y As Integer
End Type

Public Const PROCESS_ALL_ACCESS = &H1F0FFF

Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As
Long,
ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias
"ReadConsoleOutputCharacterW" (handle As Long, ByVal buffer As String,
nbcar
As Long, position As COORD, ByVal caracteres As Long) As Long


Highlight All
<!---Code--->


'1. You need Console Screen Buffer handle instead of Process handle. See
' Microsoft KB Q171654.
'
Sub Test()
Dim buff As String, position As COORD, caracteres As Long, nbcar As
Long, handle As Long, Processus As Long

Processus = Shell("C:test.bat")
handle = OpenProcess(PROCESS_ALL_ACCESS, 0, Processus)

position.X = 1
position.Y = 1
nbcar = 100

buff = String(nbcar + 1, " ")
msg = ReadConsoleOutputCharacter(handle, buff, nbcar, position,
caracteres)
MsgBox caracteres

End Sub;


No Comments to show

Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2017 snippetlibrary.com All Rights Reserved. Conditions