Sign in to follow this  

Problem closing handle from OpenDesktop

This topic is 4716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm having problems closing the handle from OpenDesktop. I have a app which interacts with the desktop. Every 5 sec, it searchs the desktop. I call the OpenDesktop func in Visual C++, do my thing, then I call CloseDesktop when I'm finished. Hence while( running == true) { if(time > 5.0) { hdesk = OpenDesktop(..); .... ..do something CloseDesktop(hdesk); } } I get an error 170 (ERROR_BUSY) when I try to close the handle. The app itself still works, but as you can imagine I run out of handles eventually because the the hdesk handle is not closed and each call to open gives me a new handle. I could just call OpenDesktop once and save the handle in a variable, but I would like to know why I can't close the handle in the 1st place. Thanks.

Share this post


Link to post
Share on other sites
DId you make a call to CreateDesktop to create the desktop first? Then you would call OpenDesktop to obtain the object - but no memory is created with the open, only with the create. You would only call CloseDesktop after the program is done because "The CloseDesktop function will fail if any thread in the calling process is using the specified desktop handle or if the handle refers to the initial desktop of the calling process.".

Disclaimer - I have never heard of these functions before - all of what I have posted are form just looking over the MSDN and not actually trying this myself [smile]. I hope it can be of some use!

- Drew

Share this post


Link to post
Share on other sites
Don't worry about closing the handle to the desktop of the calling process.

Just call OpenDesktop once at the start of the program, and store that value.

Share this post


Link to post
Share on other sites

This topic is 4716 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this