1

I'm developing a console application using c#. In this application i need to use dism command to enable some windows features.

I noticed that in the older versions of dism (previous to the 10.0 version) dism doesn't display a loading bar while performing his actions, so the process seems like strucked.

To better inform the user that the process isn't struck but it's working in backgorund, i thought to change the mouse pointer to the wait cursor.

I've tried both this code lines, from other SO questions:

Cursor.Current = Cursors.WaitCursor;
Application.DoEvents();

and

Application.UseWaitCursor = true;

but the pointer is not changing.

Is possible to change the mouse pointer in a console application?

S.Orioli
  • 443
  • 6
  • 21
  • Possible duplicate of [How can I make the cursor turn to the wait cursor?](https://stackoverflow.com/questions/1568557/how-can-i-make-the-cursor-turn-to-the-wait-cursor) – Liam May 31 '19 at 08:48
  • That question use winforms, i'm asking about a console app. I've stated that i've tried that solution but is not working. – S.Orioli May 31 '19 at 08:50
  • What about [`Cursor.Current`](https://stackoverflow.com/a/1568562/542251)? Are firing `DoEvents`? You've tried **one** of those solutions. [There is no difference between console vs windows apps apart from some trivial header information](https://stackoverflow.com/a/6716292/542251). – Liam May 31 '19 at 09:39
  • Yes i've tried calling `DoEvents()` too but with no luck. Are those solutions supposed to work in a console app? – S.Orioli May 31 '19 at 09:41
  • Yes. [*The mouse you want to control is in windows, not the console.*](https://stackoverflow.com/a/6716292/542251) – Liam May 31 '19 at 09:42
  • 3
    No can do. The console window is owned by a different process (conhost.exe) and there is no winapi function to alter the cursor shape it uses. Having (almost) no control over that window is by design, conhost.exe acts as a security barrier so nobody can mess with that window. – Hans Passant May 31 '19 at 10:03
  • @HansPassant -- Not that it'd be worth it, but couldn't you subclass the window returned by `GetConsoleWindow` and work some magic? Like what they are doing here: https://stackoverflow.com/questions/21345232/handling-drag-and-drop-files-in-a-running-windows-console-application – Andy Aug 21 '20 at 21:03

0 Answers0