开发者

VB.net sendmessge to console box

Hey all, i am trying to send some text to a console box (dos box) from my vb program but i can not seem to get it working.

Here is my current code:

Dim blah As Long
Private Const WM_GETTEXT As Integer = &HD
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As S开发者_JS百科tring) As IntPtr

blah = FindWindow1(vbNullString, "Form1")
blah = FindWindowEx(blah, vbNullString, "ConsoleWindowClass", vbNullString)
Debug.Print(blah)
SendMessage(blah, WM_SETTEXT, 200, "A")

Though that does work, it only puts a A for the title bar and not within the console.

Any help would be great! :o)

David


I've not tried it but I think you might want to look at AttachConsole to attach your process to the console of the command line process. Then you should be able to use the Console.WriteLine and similar methods I'd assume.

You can find a sample (in C#, but should be easy to convert to VB using one of the online converters) on the PInvoke page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜