Is there some API that can tell if a Variable is out of scope? Or some way I can invalidate the variable so as not to cause a "crash" in a dll?
In my case (this is a bad example, but will give you the idea) lets say my variable is "HwndMain" and its value is the handle to my window. Now lets say I have a message box that pops up, waiting for a reply, but I close the window that "HwndMain" holds the value for, and then answer the msgbox. Now the variable still has the value, but the handle is invalid, so if I send something to it, I can cause a "crash"
I could use IsWindow(HwndMain) to verify, but I am thinking in more general terms of a function like "IsVariableValid(HwndMain)"
Is this possible? or do I just have to go back and bulletproof for silly things like closing a window that is about to be used?
(Bad example I know, but it is the only one I can think of to describe the problem)
In my case (this is a bad example, but will give you the idea) lets say my variable is "HwndMain" and its value is the handle to my window. Now lets say I have a message box that pops up, waiting for a reply, but I close the window that "HwndMain" holds the value for, and then answer the msgbox. Now the variable still has the value, but the handle is invalid, so if I send something to it, I can cause a "crash"
I could use IsWindow(HwndMain) to verify, but I am thinking in more general terms of a function like "IsVariableValid(HwndMain)"
Is this possible? or do I just have to go back and bulletproof for silly things like closing a window that is about to be used?
(Bad example I know, but it is the only one I can think of to describe the problem)
Comment