Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A registry key is "opened" with RegOpenKeyEx(). After the key is opened, a value is read using RegQueryValueEx().  After the key has been read, it should be closed using RegCloseKey(). Below is the code to read the queue name, displaying a message when complete.  To test, copy this code to the CLICK event of a button:

...

The queue name is returned in QueueName. Note how the buffer (cbBuf) is initialized to 512 bytes of char(0). When RegQueryValueEx() returns, cbBuf contains the length of the return value, including the char(0) which is the delimiter. The actual queue name is everything except the char(0).  This is a common technique in calling Windows APIs that return a variable length string.

...

The code above will not run until the declarations for RegOpenKeyEx(), RegQueryValueEx(), and RegCloseKey() have been added. To add the declarations, do the following:

...