From: Tobias G��rgens tobi.goergens@gmail.com
--- dlls/cabinet/cabinet.spec | 2 +- dlls/cabinet/cabinet_main.c | 63 ++++++++++++++++++++++++++++++++++++ dlls/cabinet/tests/version.c | 7 ++-- 3 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/dlls/cabinet/cabinet.spec b/dlls/cabinet/cabinet.spec index 1953582e1de..4de06cf303b 100644 --- a/dlls/cabinet/cabinet.spec +++ b/dlls/cabinet/cabinet.spec @@ -1,7 +1,7 @@ @ stdcall -import GetFileVersionInfoA(str long long ptr) @ stdcall -import GetFileVersionInfoSizeA(str ptr) @ stdcall -import VerQueryValueA(ptr str ptr ptr) -@ stub GetDllVersion() +@ stdcall GetDllVersion() @ stdcall -private DllGetVersion (ptr) @ stdcall Extract(ptr str) @ stub DeleteExtractedFiles diff --git a/dlls/cabinet/cabinet_main.c b/dlls/cabinet/cabinet_main.c index b35226b2c9d..4de1d817a1a 100644 --- a/dlls/cabinet/cabinet_main.c +++ b/dlls/cabinet/cabinet_main.c @@ -132,6 +132,69 @@ VOID WINAPI DllGetVersion(PCABINETDLLVERSIONINFO cabVerInfo) } }
+/*********************************************************************** + * GetDllVersion (CABINET.2) + * + * Returns the version of the Cabinet.dll + * + * PARAMS + * This function has to parameters + * + * RETURNS + * Success: cabDllVer: string of Cabinet.dll version + * Failure: empty string. + * Use GetLastError() to find out more about why the function failed + * + */ + +LPCSTR WINAPI GetDllVersion(void) +{ + PCABINETDLLVERSIONINFO cabVerInfo; + LPSTR cabDllVer; + int sizeVerInfo; + DWORD FileVersionMS; + DWORD FileVersionLS; + int majorV; + int minorV; + int buildV; + int revisV; + + cabVerInfo = malloc(sizeof(CABINETDLLVERSIONINFO)); + if(cabVerInfo == NULL) { + SetLastError(ERROR_OUTOFMEMORY); + TRACE("Cannot create cabVerInfo: Out of memory: Error = %ld.\n", GetLastError()); + return ""; + } + + DllGetVersion(cabVerInfo); + if (cabVerInfo->cbStruct==0) { + TRACE("Cannot access struct: The length of the version information structure is 0: Error = %ld.\n", GetLastError()); + return ""; + } + + FileVersionMS = cabVerInfo->dwFileVersionMS; + FileVersionLS = cabVerInfo->dwFileVersionLS; + + /*length of 4 DWORDs + buffer*/ + sizeVerInfo = 32; + + cabDllVer = malloc(sizeVerInfo); + if (cabDllVer == NULL) { + SetLastError(ERROR_OUTOFMEMORY); + TRACE("Cannot create cabDllVer: Out of memory: Error = %ld.\n", GetLastError()); + return ""; + } + + majorV = (int)( FileVersionMS >> 16 ) & 0xffff; + minorV = (int)( FileVersionMS >> 0 ) & 0xffff; + buildV = (int)( FileVersionLS >> 16 ) & 0xffff; + revisV = (int)( FileVersionLS >> 0 ) & 0xffff; + + snprintf(cabDllVer, sizeVerInfo, "%d.%d.%d.%d\n",majorV,minorV,buildV,revisV); + + return cabDllVer; +} + /* FDI callback functions */
static void * CDECL mem_alloc(ULONG cb) diff --git a/dlls/cabinet/tests/version.c b/dlls/cabinet/tests/version.c index 3b4040ad383..5c7f0fbc6ec 100644 --- a/dlls/cabinet/tests/version.c +++ b/dlls/cabinet/tests/version.c @@ -59,11 +59,8 @@ static void test_dllget(HMODULE libHandle) static void test_getdll(HMODULE libHandle) { f_getdll GetDllVersion = (f_getdll)GetProcAddress(libHandle, "GetDllVersion"); - todo_wine { - /* FIXME - Currently GetDllVersion isn't implemented */ - ok(libHandle != NULL, "Function GetDllVersion in DLL not found: Error = %ld.\n", GetLastError()); - ok(strcmp(GetDllVersion(),"") != 0, "GetDllVersion doesn't return correct version: Error = %ld.\n", GetLastError()); - } + ok(libHandle != NULL, "Function GetDllVersion in DLL not found: Error = %ld.\n", GetLastError()); + ok(strcmp(GetDllVersion(),"") != 0, "GetDllVersion doesn't return correct version: Error = %ld.\n", GetLastError()); }
START_TEST(version)