diff options
author | George Hazan <george.hazan@gmail.com> | 2012-08-14 14:55:43 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-08-14 14:55:43 +0000 |
commit | 88fdd523bdf7cd891dbbac4b1ae7fb2ff597cea3 (patch) | |
tree | 9401068579f21f8336e56189de0e3065c2789ff6 /src/core | |
parent | f4a0cae037bc54f6e14aee7366ee9c635ac7df81 (diff) |
MS_SYSTEM_GETFILEVERSION added
git-svn-id: http://svn.miranda-ng.org/main/trunk@1454 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/miranda.cpp | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index 0ad716daf9..9f0da67b09 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -375,7 +375,7 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM) GetModuleFileName(NULL, filename, SIZEOF(filename));
DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
- PVOID pVerInfo = mir_alloc(verInfoSize);
+ PVOID pVerInfo = _alloca(verInfoSize);
GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo);
UINT blockSize;
@@ -385,28 +385,45 @@ static INT_PTR GetMirandaVersion(WPARAM, LPARAM) ((vsffi->dwProductVersionMS&0xFF)<<16)|
(((vsffi->dwProductVersionLS>>16)&0xFF)<<8)|
(vsffi->dwProductVersionLS&0xFF);
- mir_free(pVerInfo);
return (INT_PTR)ver;
}
-static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
+static INT_PTR GetMirandaFileVersion(WPARAM, LPARAM lParam)
{
- TCHAR filename[MAX_PATH], *productVersion;
- DWORD unused;
- DWORD verInfoSize;
+ TCHAR filename[MAX_PATH];
+ GetModuleFileName(NULL, filename, SIZEOF(filename));
+
+ DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
+ PVOID pVerInfo = _alloca(verInfoSize);
+ GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo);
+
UINT blockSize;
- PVOID pVerInfo;
+ VS_FIXEDFILEINFO *vsffi;
+ VerQueryValue(pVerInfo, _T("\\"), (PVOID*)&vsffi, &blockSize);
+ WORD* p = (WORD*)lParam;
+ p[0] = HIWORD(vsffi->dwProductVersionMS);
+ p[1] = LOWORD(vsffi->dwProductVersionMS);
+ p[2] = HIWORD(vsffi->dwProductVersionLS);
+ p[3] = LOWORD(vsffi->dwProductVersionLS);
+ return 0;
+}
+
+static INT_PTR GetMirandaVersionText(WPARAM wParam, LPARAM lParam)
+{
+ TCHAR filename[MAX_PATH], *productVersion;
GetModuleFileName(NULL, filename, SIZEOF(filename));
- verInfoSize = GetFileVersionInfoSize(filename, &unused);
- pVerInfo = mir_alloc(verInfoSize);
+
+ DWORD unused, verInfoSize = GetFileVersionInfoSize(filename, &unused);
+ PVOID pVerInfo = _alloca(verInfoSize);
GetFileVersionInfo(filename, 0, verInfoSize, pVerInfo);
+
+ UINT blockSize;
VerQueryValue(pVerInfo, _T("\\StringFileInfo\\000004b0\\ProductVersion"), (LPVOID*)&productVersion, &blockSize);
strncpy((char*)lParam, _T2A(productVersion), wParam);
#if defined(_WIN64)
strcat_s((char*)lParam, wParam, " x64");
#endif
- mir_free(pVerInfo);
return 0;
}
@@ -452,6 +469,7 @@ int LoadSystemModule(void) CreateServiceFunction(MS_SYSTEM_TERMINATED, MirandaIsTerminated);
CreateServiceFunction(MS_SYSTEM_OKTOEXIT, OkToExit);
CreateServiceFunction(MS_SYSTEM_GETVERSION, GetMirandaVersion);
+ CreateServiceFunction(MS_SYSTEM_GETFILEVERSION, GetMirandaFileVersion);
CreateServiceFunction(MS_SYSTEM_GETVERSIONTEXT, GetMirandaVersionText);
CreateServiceFunction(MS_SYSTEM_WAITONHANDLE, WaitOnHandle);
CreateServiceFunction(MS_SYSTEM_REMOVEWAIT, RemoveWait);
|