- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
HRESULT GetOutlookVersionString(LPSTR* ppszVer, BOOL* pf64Bit)
{
HRESULT hr = E_FAIL;
LPSTR pszTempPath = NULL;
LPSTR pszTempVer = NULL;
TCHAR pszaOutlookQualifiedComponents[][MAX_PATH] = {
TEXT("{1E77DE88-BCAB-4C37-B9E5-073AF52DFD7A}"), // Outlook 2010
TEXT("{24AAE126-0911-478F-A019-07B875EB9996}"), // Outlook 2007
TEXT("{BC174BAD-2F53-4855-A1D5-0D575C19B1EA}") // Outlook 2003
};
int nOutlookQualifiedComponents = _countof(pszaOutlookQualifiedComponents);
int i = 0;
DWORD dwValueBuf = 0;
UINT ret = 0;
*pf64Bit = FALSE;
for (i = 0; i < nOutlookQualifiedComponents; i++)
{
ret = MsiProvideQualifiedComponent(
pszaOutlookQualifiedComponents[i],
TEXT("outlook.x64.exe"),
(DWORD) INSTALLMODE_DEFAULT,
NULL,
&dwValueBuf);
if (ERROR_SUCCESS == ret) break;
}
if (ret != ERROR_SUCCESS)
{
ret = MsiProvideQualifiedComponent(
pszaOutlookQualifiedComponents[i],
TEXT("outlook.exe"),
(DWORD) INSTALLMODE_DEFAULT,
NULL,
&dwValueBuf);
}
else
{
*pf64Bit = TRUE;
}
if (ret == ERROR_SUCCESS)
{
dwValueBuf += 1;
pszTempPath = (LPSTR) malloc(dwValueBuf * sizeof(TCHAR));
if (pszTempPath != NULL)
{
if ((ret = MsiProvideQualifiedComponent(
pszaOutlookQualifiedComponents[i],
TEXT("outlook.exe"),
(DWORD) INSTALLMODE_EXISTING,
pszTempPath,
&dwValueBuf)) != ERROR_SUCCESS)
{
goto Error;
}
pszTempVer = (LPSTR) malloc(MAX_PATH * sizeof(TCHAR));
dwValueBuf = MAX_PATH;
if ((ret = MsiGetFileVersion(pszTempPath,
pszTempVer,
&dwValueBuf,
NULL,
NULL))!= ERROR_SUCCESS)
{
goto Error;
}
*ppszVer = pszTempVer;
pszTempVer = NULL;
hr = S_OK;
}
}
Error:
free(pszTempVer);
free(pszTempPath);
return hr;
}
Говнокод от САМОГО Билли... 21 век на дворе, а у нас в C++ коде goto Error написано (точнее - накакано).
Источник - http://msdn.microsoft.com/en-us/library/dd941331.aspx