JohnOne Posted September 16, 2014 Share Posted September 16, 2014 (edited) System.Drawing.Graphics Creating a simple screen capture class, and getting an error I've not seen before.Wondering if any of you folks now anything about it. The error is this.. win32exception the specified program requires a newer version of windowsThe weird thing is it runs in the IDE (VS2010) and I'm running win 7.But the production exe produces the error.The Documentation does not say it needs win 8 or higher, and a remark suggests it is good for win XP. Here is the offending code.hGfx = Graphics.FromImage(hBmp); hGfx.CopyFromScreen( x, y, 0, 0, size);Cannot find a close enough match for the full error in web search.EDIT:Sorry it is the CopyFromScreen method that causes it, not FromImage.EDIT2: (+1)Also, if anyone knows, how expensive are Thread safe delegate calls to get a property from form?My thread employs a tight loop and it needs to know when a property of the form changes, so might need to check the property each iteration, unless I can find a way for a form event handler to run in my worker thread. Edited September 16, 2014 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
jaberwacky Posted September 16, 2014 Share Posted September 16, 2014 The only thing I can say is that if the error only crops up in the production exe then there are some compiler settings that you should investigate. I'm no expert on this so take that as you will. JohnOne 1 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
Solution jvanegmond Posted September 16, 2014 Solution Share Posted September 16, 2014 When it runs in Visual Studio in Debug mode but not in production when you build it for Release, then optimizations are immediately suspect. Try this: using (hGfx = Graphics.FromImage(hBmp)) { hGfx.CopyFromScreen(x, y, 0, 0, size); } Also found this on with a similar problem and same solution: http://stackoverflow.com/questions/6788276/runtime-error-after-taking-screenshots-in-net JohnOne 1 github.com/jvanegmond Link to comment Share on other sites More sharing options...
JohnOne Posted September 16, 2014 Author Share Posted September 16, 2014 Cheers Manadar, this helped from the link you provided. 1. "System.ComponentModel.Win32Exception (0x80004005): The parameter is incorrect" in CopyFromScreen occurs when there's no primary desktop visible - for example, in service mode, or (in my case) when user presses "Ctrl-Alt-Del" in Windows 7/8. Although my desktop is indeed visible, the window I was capturing was not, needed to change where the code was called from. Thanks. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now