mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-14 20:25:38 +00:00
scrrun: Implement GetFileVersion().
This commit is contained in:
parent
f2eb6d018f
commit
b6eaf8761d
|
@ -1,5 +1,5 @@
|
|||
MODULE = scrrun.dll
|
||||
IMPORTS = uuid oleaut32
|
||||
IMPORTS = uuid oleaut32 version
|
||||
|
||||
C_SRCS = \
|
||||
dictionary.c \
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "scrrun_private.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
|
||||
|
||||
|
@ -933,12 +934,53 @@ static HRESULT WINAPI filesys_GetStandardStream(IFileSystem3 *iface,
|
|||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR FileName,
|
||||
BSTR *FileVersion)
|
||||
static void get_versionstring(VS_FIXEDFILEINFO *info, WCHAR *ver)
|
||||
{
|
||||
FIXME("%p %s %p\n", iface, debugstr_w(FileName), FileVersion);
|
||||
static WCHAR fmtW[] = {'%','d','.','%','d','.','%','d','.','%','d',0};
|
||||
DWORDLONG version;
|
||||
WORD a, b, c, d;
|
||||
|
||||
return E_NOTIMPL;
|
||||
version = (((DWORDLONG)info->dwFileVersionMS) << 32) + info->dwFileVersionLS;
|
||||
a = (WORD)( version >> 48);
|
||||
b = (WORD)((version >> 32) & 0xffff);
|
||||
c = (WORD)((version >> 16) & 0xffff);
|
||||
d = (WORD)( version & 0xffff);
|
||||
|
||||
sprintfW(ver, fmtW, a, b, c, d);
|
||||
}
|
||||
|
||||
static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR name, BSTR *version)
|
||||
{
|
||||
static const WCHAR rootW[] = {'\\',0};
|
||||
VS_FIXEDFILEINFO *info;
|
||||
WCHAR ver[30];
|
||||
void *ptr;
|
||||
DWORD len;
|
||||
BOOL ret;
|
||||
|
||||
TRACE("%p %s %p\n", iface, debugstr_w(name), version);
|
||||
|
||||
len = GetFileVersionInfoSizeW(name, NULL);
|
||||
if (!len)
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
|
||||
ptr = heap_alloc(len);
|
||||
if (!GetFileVersionInfoW(name, 0, len, ptr))
|
||||
{
|
||||
heap_free(ptr);
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
ret = VerQueryValueW(ptr, rootW, (void**)&info, &len);
|
||||
heap_free(ptr);
|
||||
if (!ret)
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
|
||||
get_versionstring(info, ver);
|
||||
*version = SysAllocString(ver);
|
||||
TRACE("version=%s\n", debugstr_w(ver));
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static const struct IFileSystem3Vtbl filesys_vtbl =
|
||||
|
|
|
@ -217,6 +217,43 @@ todo_wine {
|
|||
DeleteFileW(testfileW);
|
||||
}
|
||||
|
||||
static void test_GetFileVersion(void)
|
||||
{
|
||||
static const WCHAR k32W[] = {'\\','k','e','r','n','e','l','3','2','.','d','l','l',0};
|
||||
static const WCHAR k33W[] = {'\\','k','e','r','n','e','l','3','3','.','d','l','l',0};
|
||||
WCHAR pathW[MAX_PATH], filenameW[MAX_PATH];
|
||||
BSTR path, version;
|
||||
HRESULT hr;
|
||||
|
||||
GetSystemDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR));
|
||||
|
||||
lstrcpyW(filenameW, pathW);
|
||||
lstrcatW(filenameW, k32W);
|
||||
|
||||
path = SysAllocString(filenameW);
|
||||
hr = IFileSystem3_GetFileVersion(fs3, path, &version);
|
||||
ok(hr == S_OK, "got 0x%08x\n", hr);
|
||||
ok(*version != 0, "got %s\n", wine_dbgstr_w(version));
|
||||
SysFreeString(version);
|
||||
SysFreeString(path);
|
||||
|
||||
lstrcpyW(filenameW, pathW);
|
||||
lstrcatW(filenameW, k33W);
|
||||
|
||||
path = SysAllocString(filenameW);
|
||||
version = (void*)0xdeadbeef;
|
||||
hr = IFileSystem3_GetFileVersion(fs3, path, &version);
|
||||
ok(broken(hr == S_OK) || hr == HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND), "got 0x%08x\n", hr);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
ok(*version == 0, "got %s\n", wine_dbgstr_w(version));
|
||||
SysFreeString(version);
|
||||
}
|
||||
else
|
||||
ok(version == (void*)0xdeadbeef, "got %p\n", version);
|
||||
SysFreeString(path);
|
||||
}
|
||||
|
||||
START_TEST(filesystem)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -233,6 +270,7 @@ START_TEST(filesystem)
|
|||
test_interfaces();
|
||||
test_createfolder();
|
||||
test_textstream();
|
||||
test_GetFileVersion();
|
||||
|
||||
IFileSystem3_Release(fs3);
|
||||
|
||||
|
|
Loading…
Reference in a new issue