Invalid handle?

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.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Print | posted @ Monday, June 15, 2009 5:16 AM

Comments on this entry:

No comments posted yet.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: