Red Gate forums :: View topic - WriteConsoleInput
Return to RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
PInvoke.Net forum


Search in PInvoke.Net forum
Post new topic   Reply to topic
Jump to:  
Author Message

Joined: 27 Jul 2007
Posts: 1

PostPosted: Fri Jul 27, 2007 4:13 am    Post subject: WriteConsoleInput Reply with quote

I am using AttachConsole to grab a .Net Console App in C# which is working - I can send it a Ctrl-C or print to its console which is very neat. I am really getting hung up on sending input into the Console App however.

I have been trying to use WriteConsoleInput, but getting stuck in various ways.

//here are my declarations
static extern bool WriteConsoleInput(IntPtr hConsoleInput, INPUT_RECORD[] lpBuffer, uint nLength, out uint lpNumberOfEventsWritten);

[DllImport("kernel32.dll", EntryPoint = "GetStdHandle", SetLastError = True, CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
private static extern int GetStdHandle(int nStdHandle);

//I want to do this
rHnd = GetStdHandle(STD_INPUT_HANDLE);

//but I don't know how to access the definition of HANDLE, or the definition of STD_INPUT_HANDLE, I tried using (IntPtr)0xFFFFFFF6 for STD_INPUT_HANDLE but got an int overflow

//Then once I have the handle I would like to plug it into WriteConsoleInput, which I think I can figure out, but any examples would be appreciated, I basically just want to send it a few characters and {enter}

Really do appreciate any help.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group