If your application is designed to run in a non-Remote Desktop Services environment, but you would like the application to provide additional functionality when it does run in a Remote Desktop Services environment, the application can use the Remote Desktop Services API to implement the additional functionality, and dynamically link to the Wtsapi32.dll at run time. To do this, your application should call the
LoadLibrary function to load Wtsapi32.dll. If the LoadLibrary call fails, your application can run using its basic functionality. If LoadLibrary succeeds, your application can call the
GetProcAddress function to retrieve pointers to the Remote Desktop Services functions that you want to call.
If your application is intended only for a Remote Desktop Services environment, dynamic linking is not necessary. In this case, you can include Wtsapi32.h and link with Wtsapi32.lib. Then, if your application starts up in a non-Remote Desktop Services environment, it will exit because Wtsapi32.dll is not present.
For information about determining whether your application is running in a Remote Desktop Services environment, see
Detecting the Remote Desktop Services Environment.
Send comments about this topic to Microsoft
Build date: 10/19/2009