[C#.NET] Set Window Position + Eject CD Drive

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

Looking to be able to set the position of a third party app on the users screen and possibly minimize it. I am guessing you need API calls for this, but I don't know which ones to use or how to implement them.

Also looking to be able to eject an optical drive (cd drive) - but again don't know how to do this.

Any help would be appreciated? If posting code for API calls, I haven't really used them before, so a little explanation about the parameters would be nice.

Thanks.
 
Cheers guys - both worked perfectly, but I did find that if I set the position of an application to off screen, for some reason it killed it, but i have found a work around.


=========

How do I kill a c#.net application without it running any more code in the initializing function of a form:

Code:
        public MainForm()
        {
            InitializeComponent();

            // I want to kill it here.
        }
 
If the form in question is your main application form, can you determine whether you want to abort from within the Main() method of your app before the form is constructed i.e. before the call to Application.Run(new MainForm()) ?

Exactly what I needed.

Thank again guys!


=====

I am trying to be able to put in some code for unhandled errors, should i just add logic for the following events (which i know how to do), but will that cover everything?:

Code:
Application.ThreadException
AppDomain.CurrentDomain.UnhandledException

...because it doesn't seem to when i put the logic in the form, but it doesn't seem to track some of the errors, like NullException...etc...
 
Last edited:
Back
Top Bottom