Do you need the oimageviewer? What if you just call it straight
try
{
System.Diagnostics.Process.Start(@File_nme);
}
>Hello All.
>
>This one is driving me crazy (yes, I know that it is a short drive).
>
>I am using the following code to do a print screen and display it. It works just fine on my Wondows XP machine. The goofy thing is that on Windows 7 machines, it launches the process, displays the image and then immediately displays an error on this line:
>
>oImageViewer.WaitForExit(-1);
>
>because, indeed, oImageViewer is null. What's up with this and how do I fix it?
>
>
> private void cmdPrintScreen_Click(object sender, EventArgs e)
> {
> string File_nme = PrintScreen();
> if (File_nme != "")
> {
> try
> {
> using (System.Diagnostics.Process oImageViewer = System.Diagnostics.Process.Start(@File_nme))
> {
> oImageViewer.WaitForExit(-1);
> }
> }
> catch (Exception Ex)
> {
> MessageForm.ShowMessage("Screen print failed", String.Format("Unable to print the screen because{0}{1}", Environment.NewLine, Ex.Message),
> "", MessageFunction.OK, MessagingIcon.Information, MessagingSounds.None);
> }
> finally
> {
> File.Delete(File_nme);
> }
> }
> }
>
Charles Hankey
Though a good deal is too strange to be believed, nothing is too strange to have happened.
- Thomas Hardy
Half the harm that is done in this world is due to people who want to feel important. They don't mean to do harm-- but the harm does not interest them. Or they do not see it, or they justify it because they are absorbed in the endless struggle to think well of themselves.
-- T. S. Eliot
Democracy is two wolves and a sheep voting on what to have for lunch.
Liberty is a well-armed sheep contesting the vote.
- Ben Franklin
Pardon him, Theodotus. He is a barbarian, and thinks that the customs of his tribe and island are the laws of nature.