flat assembler
Message board for the users of flat assembler.

Index > Windows > Should I always validate the handle?

Author
Thread Post new topic Reply to topic
upsurt



Joined: 14 Jan 2014
Posts: 51
upsurt
Hello Guys

I've a small program looking for a specific window.
If finds the window, the login button will be clicked.
So far everything looks fine. But my question is,
should I validate the handle, if the window was
found or not and jump somewhere else, if not?
By now it would search, if not found it will try to
click the button, but the handle is null. Seems like
fasm handles this quite good. but what would you say?

thank you!
Post 20 May 2014, 06:33
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
What type of handles are you talking about? If you are using FindWindow to look for a window, then it will return NULL if the window cannot be found. Further feeding in NULL as the parent window handle to an API such as FindWindowEx will likely result in another NULL return. Sending message to a NULL window would also likely fail. But the point is you are relying on strictly defined behaviour of these APIs in the error/invalid-parameter path, which I would avoid if I could. So personally, I would check the return value of each step of your program, and "jump somewhere else" if anything fails.
Post 24 May 2014, 07:38
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
upsurt



Joined: 14 Jan 2014
Posts: 51
upsurt
Thank you very much, comrade!
Post 28 May 2014, 05:46
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.