Geeks With Blogs
Windows Embedded Annotations

Several Windows Embedded CE API's deal with handles: an application obtains a handle to an object than it typically checks if the handle is valid or not; unfortunately there are two values which means invalid handle: for example CreateFile returns INVALID_HANDLE_VALUE (which is defined as -1 or 0xFFFFFFFF) while CreateEvent returns NULL.

A mnemonic aid is the following: all the API's that deal with files, storage and database (CreateFile, FindFirstChangeNotification, OpenStore, CeOpenDatabaseEx, ...) return INVALID_HANDLE_VALUE while the other API's return NULL.  

Some noticeable exceptions to this statement are:

  • CreateToolhelp32Snapshot
  • FindFirstDevice
  • CeFindFirstRegChange

which returns INVALID_HANDLE_VALUE.

Note that there is an error in Windows Embedded CE documentation about OpenDeviceKey: it is stated that the function returns INVALID_HANDLE_VALUE in case of error while it actually returns NULL.

Posted on Monday, June 15, 2009 5:16 AM Windows CE | Back to top


Comments on this post: Invalid handle?

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Luca Calligaris | Powered by: GeeksWithBlogs.net