// Retrieve the OS Peak File Cache Size Setting
void readFileCachePeakSize()
{
	RAW_DATA Sample1;
	BOOL fSuccess = FALSE;

	// Retrieve the object data again and get the next sample.
	// Object 4 is Memory
	g_pPerfDataHead = (LPBYTE)GetPerformanceData(L"4", INIT_OBJECT_BUFFER_SIZE);
	if (NULL == g_pPerfDataHead)
	{
		wprintf(L"GetPerformanceData in loop failed.\n");
		goto cleanup;
	}

	// Counter 820 is Cache Bytes Peak.
	fSuccess = GetCounterValues(4, 820, L"0", &Sample1);
	if (FALSE == fSuccess)
	{
		wprintf(L"GetCounterValues failed.\n");
		goto cleanup;
	}
	wprintf(L"File sys cache bytes peak %I64u.\n", Sample1.Data);

cleanup:

	if (g_pPerfDataHead)
		free(g_pPerfDataHead);
}
int main(int argc, char *argv[])
{
    if (argc <= 1) {
        fprintf(stderr, "You must specify SQLServer instance names. Exiting...\n");
        return -1;
    }

    GetCounterValues(NULL, argc-1, &argv[1]);
}
int main(int argc, _TCHAR *argv[])
{
    int resultCode = 0; 
    DWORD dwErrorCode = PDH_NO_DATA;

    if (GetCounterValues(NULL, argc-1, &argv[1]) != ERROR_SUCCESS)
    {
      resultCode = 1;
    }
    return resultCode;
}
// Retrieve the OS File Cache Size setting
void readFileCacheSize()
{
	RAW_DATA Sample1;
	BOOL fSuccess = FALSE;
	static const int SAMPLE_CNT = 3;
	ULONGLONG dataAvg = 0L;

	// Display five data points for the counter.
	for (DWORD i = 0; i < SAMPLE_CNT; i++)
	{
		Sleep(1000);  // Wait one second before taking the next sample

		// Retrieve the object data again and get the next sample.
		// Object 4 is Memory
		g_pPerfDataHead = (LPBYTE)GetPerformanceData(L"4", INIT_OBJECT_BUFFER_SIZE);
		if (NULL == g_pPerfDataHead)
		{
			wprintf(L"GetPerformanceData in loop failed.\n");
			goto cleanup;
		}

		// Counter 818 is Cache Bytes. We are retrieving the counter for Memory/Cache Bytes.
		fSuccess = GetCounterValues(4, 818, L"0", &Sample1);
		if (FALSE == fSuccess)
		{
			wprintf(L"GetCounterValues failed.\n");
			goto cleanup;
		}
		dataAvg += Sample1.Data;
		wprintf(L"File sys cache bytes %I64u.\n", Sample1.Data);
	}
	wprintf(L"Average value is %I64u.\n", dataAvg / SAMPLE_CNT);

cleanup:

	if (g_pPerfDataHead)
		free(g_pPerfDataHead);
}