WriteConsoleOutput [英] WriteConsoleOutput

查看:96
本文介绍了WriteConsoleOutput的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有一个声明和使用WriteConsoleOutput

Win32 API函数的例子?我在理解如何将所有结构转换为VB.NET时遇到一些麻烦。具体来说,我试图将

纯文本,回车键,F3键,箭头键等发送到控制台窗口我已经附加了。

已附加。


谢谢,


Doug

解决方案

Doug,

有没有人有一个声明和使用WriteConsoleOutput
Win32 API函数的例子?




我没有任何如何使用它的例子,但我会声明它像

这个


声明自动函数WriteConsoleOutput Lib" kernel32.dll" (ByVal

hConsoleOutput作为IntPtr,ByVal lpBuffer(,)作为CHAR_INFO,ByVal

dwBufferSize作为COORD,ByVal dwBufferCoord作为COORD,ByRef

lpWriteRegion作为SMALL_RECT)作为布尔值


Mattias


-

Mattias Sj?gren [MVP] mattias @ mvps .org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com

请回复到新闻组。


对不起,我打算输入WriteConsoleInput。 ;-(


有人可以帮我写一下

WriteConsoleInput的结构和声明。我对INPUT_RECORD结构非常困惑以及如何

用VB创建它吗?


谢谢,


Doug


" Mattias Sj?gren"< ma ******************** @ mvps.org>在留言中写道

news:OU *** ********** @ TK2MSFTNGP11.phx.gbl ...

Doug,

有没有人有一个声明和使用的例子WriteConsoleOutput
Win32 API函数?



我没有任何关于如何使用它的例子,但我会声明它像
这个

声明自动函数WriteConsoleOutput Lib" kernel32.dll"(ByVal
hConsoleOutput As IntPtr,ByVal lpBuffer(,)作为CHAR_INFO,ByVal
dwBufferSize作为COORD,ByVal dwBufferCoord作为COORD, ByRef
lpWriteRegion作为SMALL_RECT)作为布尔值

Mattias

- Mattias Sj?gren [MVP] mattias @ mvps.org
http: //www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
请仅回复新闻组。



在文章< #K ************** @ TK2MSFTNGP09.phx.gbl>中,Doug Perkes写道:

抱歉,我的意思是输入WriteConsoleInput。 ;-(

有人可以帮我写一下
WriteConsoleInput的结构和声明。我对INPUT_RECORD结构非常困惑,以及如何在VB中创建它?

谢谢,

道格




可能是工会......我会这样做......

< StructLayout(LayoutKind.Explicit)> _

StructLayout CharUnion

< FieldOffset(0)> _

Public UnicodeChar As Short

< FieldOffset(0)> _

Public AsciiChar As Byte

End Structure

< StructLayout(LayoutKind.Sequential)> _

结构KEY_EVENT_RECORD

Public bKeyDown As Boolean

Public wReapeatCount As简短

公共wVirtualKeyCode简短

公共wVirtualScanCode简短

公共uChar作为CharUnion


' 我会在这里制作一面旗帜

'',但是一个整数仍然有效:)

Public dwControlKeyState As Integer

结束结构


< StructLayout(LayoutKind.Explicit)> _

结构EventUnion

< FieldOffset(0)> _

Public KeyEvent为KEY_EVENT_RECORD

< FieldOffset(0)> _

Public MouseEvent作为MOUSE_EVENT_RECORD

....

结束结构


< StructLayout (LayoutKind.Sequential)>

结构INPUT_RECORD

Public EventType As Short

Public Event As EventUnion

End结构


不是一套完整的定义,而是让你前进的东西。我实际上已经在C#中定义了大部分这些内容......你知道多少C#做

?如果我找到它们,我可以发布该代码。

-

Tom Shelton

MVP [Visual Basic]


Does anyone have an example of declaring and using the WriteConsoleOutput
Win32 API function? I''m having a little bit of trouble understanding how to
translate all the structures to VB.NET. Specifically, I am trying to send
plain text, the enter key, the F3 key, arrow keys, etc to a console window I
have attached to.

Thanks,

Doug

解决方案

Doug,

Does anyone have an example of declaring and using the WriteConsoleOutput
Win32 API function?



I don''t have any example of how to use it, but I''d declare it like
this

Declare Auto Function WriteConsoleOutput Lib "kernel32.dll" (ByVal
hConsoleOutput As IntPtr, ByVal lpBuffer(,) As CHAR_INFO, ByVal
dwBufferSize As COORD, ByVal dwBufferCoord As COORD, ByRef
lpWriteRegion As SMALL_RECT) As Boolean

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


Sorry, I meant to type WriteConsoleInput. ;-(

Could someone help me write the structs and declarations for
WriteConsoleInput. I am very confused by the INPUT_RECORD struct and how to
create it in VB?

Thanks,

Doug

"Mattias Sj?gren" <ma********************@mvps.org> wrote in message
news:OU*************@TK2MSFTNGP11.phx.gbl...

Doug,

Does anyone have an example of declaring and using the WriteConsoleOutput
Win32 API function?



I don''t have any example of how to use it, but I''d declare it like
this

Declare Auto Function WriteConsoleOutput Lib "kernel32.dll" (ByVal
hConsoleOutput As IntPtr, ByVal lpBuffer(,) As CHAR_INFO, ByVal
dwBufferSize As COORD, ByVal dwBufferCoord As COORD, ByRef
lpWriteRegion As SMALL_RECT) As Boolean

Mattias

--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.



In article <#K**************@TK2MSFTNGP09.phx.gbl>, Doug Perkes wrote:

Sorry, I meant to type WriteConsoleInput. ;-(

Could someone help me write the structs and declarations for
WriteConsoleInput. I am very confused by the INPUT_RECORD struct and how to
create it in VB?

Thanks,

Doug



Probably the unions... I would do something like this...

<StructLayout(LayoutKind.Explicit)> _
StructLayout CharUnion
<FieldOffset(0)> _
Public UnicodeChar As Short
<FieldOffset(0)> _
Public AsciiChar As Byte
End Structure
<StructLayout(LayoutKind.Sequential)> _
Structure KEY_EVENT_RECORD
Public bKeyDown As Boolean
Public wReapeatCount As Short
Public wVirtualKeyCode As Short
Public wVirtualScanCode As Short
Public uChar As CharUnion

'' I''d probaby make a enum of the flags
'' here, but an integer still works :)
Public dwControlKeyState As Integer
End Structure

<StructLayout(LayoutKind.Explicit)> _
Structure EventUnion
<FieldOffset(0)> _
Public KeyEvent As KEY_EVENT_RECORD
<FieldOffset(0)> _
Public MouseEvent As MOUSE_EVENT_RECORD
....
End Sturcture

<StructLayout(LayoutKind.Sequential)>
Structure INPUT_RECORD
Public EventType As Short
Public Event As EventUnion
End Structure

Not a complete set of definitions, but something to get you going. I
actually have most of these defined in C# somewhere... How much C# do
you understand? If I find them, I could post that code.
--
Tom Shelton
MVP [Visual Basic]


这篇关于WriteConsoleOutput的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆