Using the Configuration API in Visual C++
- Updated2025-10-18
- 1 minute(s) read
Include the following lines in your code to use the Switch Executive Configuration API from Visual C++:
#include "comdef.h"
Example
#include "stdafx.h"
#include "comdef.h"
#import "C:\windows\system32\nise.dll" tlbid(2) no_namespace
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr = CoInitialize(NULL);
if (SUCCEEDED(hr))
{
VirtualDevicesPtr nise(__uuidof(NiseVirtualDevices)); // creates a smart pointer, no need to destroy this one
VirtualDevice* vd; // this will hold a pointer to VirtualDevice interface.
long numDevices;
BSTR vdName;
numDevices = nise->GetCount(); // get the number of virtual devices. You should have one (the example one) after default installation
vd = nise->GetItem(1); // get the first element in the collection of virtual devices. You can loop from 1 to numDevices if you want to examine the whole system
vdName = vd->GetName(); //get the name of the first configuration in a collection
SysTreeString(vdName);
vd->Release(); // vd is not a smart pointer, you should release it. Smart pointers end in "Ptr"
CoUninitialize();
}
return 0;
}