From 2da6570ca4cb9cf277c0504b2cbe2cfd84d48956 Mon Sep 17 00:00:00 2001 From: Andrew Nguyen Date: Sat, 30 Jan 2010 18:24:52 -0600 Subject: [PATCH] pdh: Implement and test PdhGetDllVersion. --- dlls/pdh/pdh.spec | 2 +- dlls/pdh/pdh_main.c | 13 +++++++++++++ dlls/pdh/tests/pdh.c | 23 +++++++++++++++++++++++ include/pdh.h | 5 +++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/dlls/pdh/pdh.spec b/dlls/pdh/pdh.spec index 3d75bb190de..b475d5392c6 100644 --- a/dlls/pdh/pdh.spec +++ b/dlls/pdh/pdh.spec @@ -57,7 +57,7 @@ @ stub PdhGetDefaultPerfObjectHA @ stub PdhGetDefaultPerfObjectHW @ stub PdhGetDefaultPerfObjectW -@ stub PdhGetDllVersion +@ stdcall PdhGetDllVersion(ptr) @ stub PdhGetFormattedCounterArrayA @ stub PdhGetFormattedCounterArrayW @ stdcall PdhGetFormattedCounterValue(ptr long ptr ptr) diff --git a/dlls/pdh/pdh_main.c b/dlls/pdh/pdh_main.c index fd6deba8e77..bdf83a94792 100644 --- a/dlls/pdh/pdh_main.c +++ b/dlls/pdh/pdh_main.c @@ -726,6 +726,19 @@ PDH_STATUS WINAPI PdhGetCounterTimeBase( PDH_HCOUNTER handle, LONGLONG *base ) } /*********************************************************************** + * PdhGetDllVersion (PDH.@) + */ +PDH_STATUS WINAPI PdhGetDllVersion( LPDWORD version ) +{ + if (!version) + return PDH_INVALID_ARGUMENT; + + *version = PDH_VERSION; + + return ERROR_SUCCESS; +} + +/*********************************************************************** * PdhGetFormattedCounterValue (PDH.@) */ PDH_STATUS WINAPI PdhGetFormattedCounterValue( PDH_HCOUNTER handle, DWORD format, diff --git a/dlls/pdh/tests/pdh.c b/dlls/pdh/tests/pdh.c index cd03bcb4fe3..094ad74f14b 100644 --- a/dlls/pdh/tests/pdh.c +++ b/dlls/pdh/tests/pdh.c @@ -934,6 +934,28 @@ static void test_PdhMakeCounterPathA(void) ok(ret == PDH_INVALID_ARGUMENT, "PdhMakeCounterPathA failed 0x%08x\n", ret); } +static void test_PdhGetDllVersion(void) +{ + PDH_STATUS ret; + DWORD version; + + ret = PdhGetDllVersion(NULL); + ok(ret == PDH_INVALID_ARGUMENT || + broken(ret == ERROR_SUCCESS), /* Vista+ */ + "Expected PdhGetDllVersion to return PDH_INVALID_ARGUMENT, got %d\n", ret); + + ret = PdhGetDllVersion(&version); + ok(ret == ERROR_SUCCESS, + "Expected PdhGetDllVersion to return ERROR_SUCCESS, got %d\n", ret); + + if (ret == ERROR_SUCCESS) + { + ok(version == PDH_CVERSION_WIN50 || + version == PDH_VERSION, + "Expected version number to be PDH_CVERSION_WIN50 or PDH_VERSION, got %u\n", version); + } +} + START_TEST(pdh) { if (PRIMARYLANGID(LANGIDFROMLCID(GetThreadLocale())) != LANG_ENGLISH) @@ -975,4 +997,5 @@ START_TEST(pdh) test_PdhCollectQueryDataEx(); test_PdhMakeCounterPathA(); + test_PdhGetDllVersion(); } diff --git a/include/pdh.h b/include/pdh.h index f4764af3505..7f3d3340b21 100644 --- a/include/pdh.h +++ b/include/pdh.h @@ -37,6 +37,10 @@ typedef HANDLE PDH_HQUERY; typedef HANDLE PDH_HCOUNTER; typedef HANDLE PDH_HLOG; +#define PDH_CVERSION_WIN40 0x0400 +#define PDH_CVERSION_WIN50 0x0500 +#define PDH_VERSION 0x0503 + #define PDH_MAX_SCALE 7 #define PDH_MIN_SCALE (-7) @@ -186,6 +190,7 @@ PDH_STATUS WINAPI PdhGetCounterInfoA(PDH_HCOUNTER, BOOLEAN, LPDWORD, PPDH_COUNTE PDH_STATUS WINAPI PdhGetCounterInfoW(PDH_HCOUNTER, BOOLEAN, LPDWORD, PPDH_COUNTER_INFO_W); #define PdhGetCounterInfo WINELIB_NAME_AW(PdhGetCounterInfo) PDH_STATUS WINAPI PdhGetCounterTimeBase(PDH_HCOUNTER, LONGLONG *); +PDH_STATUS WINAPI PdhGetDllVersion(LPDWORD); PDH_STATUS WINAPI PdhGetFormattedCounterValue(PDH_HCOUNTER, DWORD, LPDWORD, PPDH_FMT_COUNTERVALUE); PDH_STATUS WINAPI PdhGetRawCounterValue(PDH_HCOUNTER, LPDWORD, PPDH_RAW_COUNTER); PDH_STATUS WINAPI PdhLookupPerfIndexByNameA(LPCSTR, LPCSTR, LPDWORD); -- 2.11.4.GIT