Platform SDK: Performance Monitoring |
The system calls the Open function whenever an application first connects to the registry to collect performance data. This function performs the initialization required for the application to provide performance data.
Use the following function prototype for your Open function.
DWORD CALLBACK OpenPerformanceData(LPWSTR lpDeviceNames);
The name OpenPerformanceData is a placeholder for an application-defined name. The lpDeviceNames argument points to a buffer containing the Unicode strings stored in the Export value in the following registry key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\
Application_Name\Linkage
The strings are REG_MULTI_SZ strings, separated by a UNICODE_NULL, and terminated by two UNICODE_NULL characters. If this entry does not exist, lpDeviceNames should be NULL. The strings are the names of the devices managed by this application. The Open function should call the CreateFile function to open a handle to each device named. If CreateFile fails, the Open function should return the error code returned by the GetLastError function; otherwise, it should return ERROR_SUCCESS.
The Open function initializes the data structures it returns to the performance monitor application. In particular, it examines the registry to get the Counter and Help indexes of the objects and counters supported by the application. It then stores these indexes in the appropriate members of the PERF_OBJECT_TYPE and PERF_COUNTER_DEFINITION structures.
Other initialization tasks that might be performed by the Open function include the following:
The Open function should write in the system event log any error that prevents the function from completing successfully.