Sign in to follow this  
johnnyBravo

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

Recommended Posts

johnnyBravo    100
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
Demus79    362

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
Evil Steve    2017
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
Skeleton_V@T    512
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

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