Jump to content
  • Advertisement
Sign in to follow this  

c++ win32, Is using UnregisterClass required when closing program?

This topic is 4450 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 was looking through some automatic window code generated by Visual c++ 2005 beta 2, and I noticed they didn't use UnregisterClass on the window's class. I usually call UnregisterClass when i close my app, but is it actually required to be called when the program is being shutdown? Thanks

Share this post


Link to post
Share on other sites
Advertisement

According to MSDN:

- All window classes that an application registers are unregistered when it terminates.

So, it seems that it isn't necessary, perhaps just polite way of doing thing.

Share this post


Link to post
Share on other sites
You don't need to, but I do. The main reason is that if I want to restart my app for any reason (as in re-create my CApp class), if the class is already registered, RegiserClassEx will fail, meaning I'd have to quit the application completely and restart it.

Share this post


Link to post
Share on other sites
If you feel lazy, you may malloc bunches of memory, create several windows and threads then leave them while relying on the OS to do the cleaning up for you. It doesn't guarantee everything will be properly cleaned up, especially if your app is messing with other apps though. So, it is a good practice to properly alloc/free things as documented.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!