Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / January 2008

Tip: Looking for answers? Try searching our database.

Send Ctrl+C in testcase.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zlf - 12 Jan 2008 11:53 GMT
Hello
I'm writing testcase for my console application. One testcase requires to
test press Ctrl+C while the application is running.
How to send Ctrl+C while running application through
System.Diagnostics.Process?
I know I can simulate input through p.StandardInput.WriteLine, but I do not
know what exactly input string represents "Ctrl+C".

Thanks
Nicholas Paldino [.NET/C# MVP] - 14 Jan 2008 17:05 GMT
zlf,

   If you can make the console app the active application, you could use
the SendKeys class to send a key sequence to the app.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

> Hello
> I'm writing testcase for my console application. One testcase requires to
[quoted text clipped - 5 lines]
>
> Thanks
Ben Voigt [C++ MVP] - 16 Jan 2008 15:31 GMT
> Hello
> I'm writing testcase for my console application. One testcase requires to
> test press Ctrl+C while the application is running.
> How to send Ctrl+C while running application through
> System.Diagnostics.Process?

Since console applications in Windows receive that as a console control
signal through SetConsoleCtrlHandler, you'd use the matching function
GenerateConsoleCtrlEvent.

Looks like you'll need to use a process group and know the PID of the
process.

Then p/invoke to GenerateControlCtrlEvent:
http://msdn2.microsoft.com/en-us/library/ms683155(VS.85).aspx
christery@gmail.com - 17 Jan 2008 19:20 GMT
Could be silly, but not wanting the os to know then pass it ascii char
3, wont break the exec...
like Ctrl+Break that sets of OS interrupts, as do Ctrl+C, creates
events
//CY

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.