Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 118907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:34:08+00:00 2026-05-11T03:34:08+00:00

I am using the ShowWindow method from User32 to hide a window (cmd.exe) from

  • 0

I am using the ShowWindow method from User32 to hide a window (cmd.exe) from the user (mainly to prevent them from closing it). When the user opens the form, the process is started, and hid, then when the form is closing the process is killed. However, when the form is opened again, it doesn’t hide the window (and sometimes doesn’t the first time) Can someone help me with this?

    [DllImport('User32')]     private static extern int ShowWindow(int hwnd, int nCmdShow);   //this will allow me to hide a window      public ConsoleForm(Process p) {         this.p = p;         p.Start();         ShowWindow((int)p.MainWindowHandle, 0);   //0 means to hide the window. See User32.ShowWindow documentation SW_HIDE          this.inStream = p.StandardInput;         this.outStream = p.StandardOutput;         this.errorStream = p.StandardError;          InitializeComponent();          wr = new watcherReader(watchProc);         wr.BeginInvoke(this.outStream, this.txtOut, null, null);         wr.BeginInvoke(this.errorStream, this.txtOut2, null, null);     }      private delegate void watcherReader(StreamReader sr, RichTextBox rtb);     private void watchProc(StreamReader sr, RichTextBox rtb) {         string line = sr.ReadLine();         while (line != null && !stop && !p.WaitForExit(0)) {             //Console.WriteLine(line);             line = stripColors(line);             rtb.Text += line + '\n';              line = sr.ReadLine();         }     }      public void start(string[] folders, string serverPath) {          this.inStream.WriteLine('chdir C:\\cygwin\\bin');         //this.inStream.WriteLine('bash --login -i');         this.inStream.WriteLine('');     }      private void ConsoleForm_FormClosed(object sender, FormClosedEventArgs e) {         this.stop = true;         try {             this.p.Kill();             this.p.CloseMainWindow();         } catch (InvalidOperationException) {             return;         }     } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:34:09+00:00Added an answer on May 11, 2026 at 3:34 am

    It would be MUCH easier to this:

    public ConsoleForm(Process p) {         this.p = p;         p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;         p.StartInfo.CreateNoWindow = true;         p.Start();          this.inStream = p.StandardInput;         this.outStream = p.StandardOutput;         this.errorStream = p.StandardError;          InitializeComponent();          wr = new watcherReader(watchProc);         wr.BeginInvoke(this.outStream, this.txtOut, null, null);         wr.BeginInvoke(this.errorStream, this.txtOut2, null, null);     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 221k
  • Answers 221k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm not sure if this answers your question, but this… May 13, 2026 at 12:09 am
  • Editorial Team
    Editorial Team added an answer I would recommend Git with GitHub May 13, 2026 at 12:09 am
  • Editorial Team
    Editorial Team added an answer Our providers are simply wrappers for connection strings - so… May 13, 2026 at 12:09 am

Related Questions

i am using the below class to hid the task bar. but the problem
I am using the below code to disable the hotkeys like Alt + f4,
I am using the below code to block the taskbar which is working perfectly.
I am using the below class to hide and show the windows task bar.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.