Esempio n. 1
1
// 현재 실행파일의 파일 버전 얻어오기
BOOL GetCurrentFileVersion(LPTSTR tszFileVer)
{
	BOOL bRet = FALSE;
	DWORD dwInfoSize = 0;
	TCHAR tszFilePath[MAX_PATH] = {'\0',};

	char *pBuf = NULL;

	tszFileVer[0] = '\0';

	GetModuleFileName(NULL, tszFilePath, MAX_PATH);
	
	dwInfoSize = GetFileVersionInfoSize(tszFilePath, 0);
	
	pBuf = new char[dwInfoSize];
	
	if( dwInfoSize == 0 )
	{
		bRet = FALSE;
	}

	if(GetFileVersionInfo(tszFilePath, 0, dwInfoSize, pBuf) !=0 )
	{
		VS_FIXEDFILEINFO* pFineInfo = NULL;
		UINT bufLen = 0;
		if(VerQueryValue(pBuf, _T("\\"),(LPVOID*)&pFineInfo, &bufLen) !=0)
		{   
			bRet = TRUE;
			wsprintf(tszFileVer, _T("v%d.%d.%d.%d"), HIWORD(pFineInfo->dwFileVersionMS), LOWORD(pFineInfo->dwFileVersionMS), HIWORD(pFineInfo->dwFileVersionLS), LOWORD(pFineInfo->dwFileVersionLS) );
		}
	}
	
	delete pBuf;


	return bRet;
}
Esempio n. 2
0
jobject getVersion(JNIEnv * env, char *driver)
{
	DWORD var = 0;
	DWORD dwInfoSize;
	LPVOID lpInfoBuff;
	BOOL bRetval;
	jclass version_class;
	jmethodID version_cons;
	jobject ret = NULL;

	version_class = (*env)->FindClass(env, "org/lwjgl/opengl/WindowsFileVersion");
	if (version_class == NULL)
		return NULL;
	version_cons = (*env)->GetMethodID(env, version_class, "<init>", "(II)V");
	if (version_cons == NULL)
		return NULL;

	dwInfoSize = GetFileVersionInfoSize(driver, &var);
	lpInfoBuff = malloc(dwInfoSize);
	if (lpInfoBuff == NULL) {
		throwException(env, "Failed to allocate lpInfoBuff");
		return NULL;
	}
	bRetval = GetFileVersionInfo(driver, 0, dwInfoSize, lpInfoBuff);
	if (bRetval != 0) {
		VS_FIXEDFILEINFO * fxdFileInfo;

		UINT uiLen = 0;
		bRetval = VerQueryValue(lpInfoBuff, TEXT("\\"), (void *)&fxdFileInfo, &uiLen);
		if (bRetval != 0)
			ret = (*env)->NewObject(env, version_class, version_cons, fxdFileInfo->dwProductVersionMS, fxdFileInfo->dwProductVersionLS);
	}

	free(lpInfoBuff);

	return ret;
}
Esempio n. 3
0
void InitDlg(HWND hDlg) {
    // Get version information from the application
    HINSTANCE hInst = AfxGetInstanceHandle();
    TCHAR szFullPath[256];
    GetModuleFileName(hInst, szFullPath, sizeof(szFullPath));
    DWORD dwVerHnd;
    DWORD dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);

    if (dwVerInfoSize != 0) {
        // If we were able to get the information, process it
        HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
        LPVOID lpvMem = GlobalLock(hMem);
        GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
        TCHAR szGetName[256];
        lstrcpy(szGetName, _T("\\StringFileInfo\\040904b0\\"));
        int cchRoot = lstrlen(szGetName);

        // Walk through the dialog items that we want to replace
        static WORD idcs[] = {IDC_COPYRIGHT, IDC_VERSION};
        for (int i = 0; i < 2; i++) {
            TCHAR szResult[256];
            ::GetDlgItemText(hDlg, idcs[i], szResult, sizeof(szResult));
            lstrcpy(&szGetName[cchRoot], szResult);
            LPTSTR lszVer = NULL;
            UINT cchVer = 0;
            BOOL fRet = VerQueryValue(lpvMem, szGetName, (void**)&lszVer, &cchVer);

            if (fRet && cchVer != 0 && lszVer != NULL) {
                // Replace dialog item text with version info
                lstrcpy(szResult, lszVer);
                ::SetDlgItemText(hDlg, idcs[i], szResult);
            }
        }
        GlobalUnlock(hMem);
        GlobalFree(hMem);
    }
}
Esempio n. 4
0
const wchar_t* GetVersion(HMODULE hMod)
{
	static wchar_t szVersion[32];

	if (szVersion[0])
		return szVersion;

    WCHAR ModulePath[MAX_PATH*2];
    if (GetModuleFileName(hMod,ModulePath,sizeof(ModulePath)/sizeof(ModulePath[0]))) {
		DWORD dwRsrvd = 0;
		DWORD dwSize = GetFileVersionInfoSize(ModulePath, &dwRsrvd);
		if (dwSize>0) {
			void *pVerData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSize);
			if (pVerData) {
				VS_FIXEDFILEINFO *lvs = NULL;
				UINT nLen = sizeof(lvs);
				if (GetFileVersionInfo(ModulePath, 0, dwSize, pVerData)) {
					TCHAR szSlash[3]; lstrcpyW(szSlash, L"\\");
					if (VerQueryValue ((void*)pVerData, szSlash, (void**)&lvs, &nLen)) {
						wsprintfW(szVersion, L"%i.%i",
							HIWORD(lvs->dwFileVersionMS), LOWORD(lvs->dwFileVersionMS));
						if (lvs->dwFileVersionLS)
							wsprintfW(szVersion+lstrlen(szVersion), L".%i.%i",
								HIWORD(lvs->dwFileVersionLS), LOWORD(lvs->dwFileVersionLS));
					}
				}
				HeapFree(GetProcessHeap(), 0, pVerData);
			}
		}
	}

	if (!szVersion[0])
		lstrcpy(szVersion, L"Unknown");

	return szVersion;
}
Esempio n. 5
0
CString GetModuleInformation()
{
    CString info;
    TCHAR szApp[MAX_PATH];
    if(!GetModuleFileName(NULL, szApp, MAX_PATH))
        return info;

    info = szApp;

    DWORD dwDummy;
    DWORD dwInfoSize;

    dwInfoSize = GetFileVersionInfoSize(szApp, &dwDummy);
    if(dwInfoSize)
    {
        LPVOID pInfoBuffer = _alloca(dwInfoSize);
        if(GetFileVersionInfo(szApp, 0, dwInfoSize, pInfoBuffer))
        {
            VS_FIXEDFILEINFO *pInfo = NULL;
            UINT InfoSize = 0;
            if(VerQueryValue (pInfoBuffer, _T("\\"), (LPVOID *)&pInfo, &InfoSize) && InfoSize == sizeof(VS_FIXEDFILEINFO))
            {
                CString strVersion;
                strVersion.Format(_T(" (%d.%d.%d.%d)"),
                            HIWORD(pInfo->dwFileVersionMS),
                            LOWORD(pInfo->dwFileVersionMS),
                            HIWORD(pInfo->dwFileVersionLS),
                            LOWORD(pInfo->dwFileVersionLS)
                        );
                info += strVersion;
            }
        }
    }

    return info;
}
int32 FDesktopPlatformWindows::GetShellIntegrationVersion(const FString &FileName)
{
	::DWORD VersionInfoSize = GetFileVersionInfoSize(*FileName, NULL);
	if (VersionInfoSize != 0)
	{
		TArray<uint8> VersionInfo;
		VersionInfo.AddUninitialized(VersionInfoSize);
		if (GetFileVersionInfo(*FileName, NULL, VersionInfoSize, VersionInfo.GetData()))
		{
			TCHAR *ShellVersion;
			::UINT ShellVersionLen;
			if (VerQueryValue(VersionInfo.GetData(), TEXT("\\StringFileInfo\\040904b0\\ShellIntegrationVersion"), (LPVOID*)&ShellVersion, &ShellVersionLen))
			{
				TCHAR *ShellVersionEnd;
				int32 Version = FCString::Strtoi(ShellVersion, &ShellVersionEnd, 10);
				if(*ShellVersionEnd == 0)
				{
					return Version;
				}
			}
		}
	}
	return 0;
}
Esempio n. 7
0
// populateVersions
//
// This function reads the DLL's Product Version, and stores the MS and LS
// DWORDs into global variables for use in the getCUIAppLanguageModuleVersion
// function.  It also sets the versionsPopulated variable to true so that it
// will only load the information once.
void populateVersions(void)
{
	if (!versionsPopulated)
	{
		char moduleFilename[1024];

		if (GetModuleFileName(g_hModule, moduleFilename,
			sizeof(moduleFilename)) > 0)
		{
			DWORD zero;
			DWORD versionInfoSize = GetFileVersionInfoSize(moduleFilename,
				&zero);
			
			if (versionInfoSize > 0)
			{
				BYTE *versionInfo = new BYTE[versionInfoSize];

				if (GetFileVersionInfo(moduleFilename, NULL, versionInfoSize,
					versionInfo))
				{
					VS_FIXEDFILEINFO *fixedVersionInfo;
					UINT versionLength;

					if (VerQueryValue(versionInfo, "\\",
						(void**)&fixedVersionInfo, &versionLength))
					{
						versionMS = fixedVersionInfo->dwProductVersionMS;
						versionLS = fixedVersionInfo->dwProductVersionLS;
						versionsPopulated = true;
					}
				}
				delete versionInfo;
			}
		}
	}
}
Esempio n. 8
0
//////////////////
// Get string file info.
// Key name is something like "CompanyName".
// returns the value in szValue.
//
BOOL CModuleVersion::GetValue(LPCTSTR lpKeyName, CString & strVal)
{
    BOOL bRet = FALSE ;
    TCHAR szTemp [ MAX_PATH ] ;
    if ( m_pVersionInfo )
    {
        // To get a string value must pass query in the form
        //
        //    "\StringFileInfo\<langID><codepage>\keyname"
        //
        // where <langID><codepage> is the languageID concatenated with the
        // code page, in hex. Wow.
        //

        wsprintf ( szTemp ,
                  _T("\\StringFileInfo\\%04x%04x\\%s"),
                  m_translation.langID,
                  m_translation.charset,
                  lpKeyName);

        LPCTSTR pVal;
        UINT iLenVal;
        if ( VerQueryValue(m_pVersionInfo, szTemp,
                           (LPVOID*)&pVal, &iLenVal) )
        {
            LPTSTR szValue = strVal.GetBuffer (iLenVal);
			_tcsncpy ( szValue, pVal, iLenVal);
			
			strVal.ReleaseBuffer();


            bRet = TRUE ;
        }
    }
    return ( bRet );
}
/**
 * Get the 4 element version number of the module
 */
static void GetModuleVersion( TCHAR* ModuleName, TCHAR* StringBuffer, DWORD MaxSize )
{
	StringCchCopy( StringBuffer, MaxSize, TEXT( "0.0.0.0" ) );
	
	DWORD Handle = 0;
	DWORD InfoSize = GetFileVersionInfoSize( ModuleName, &Handle );
	if( InfoSize > 0 )
	{
		char* VersionInfo = new char[InfoSize];
		if( GetFileVersionInfo( ModuleName, 0, InfoSize, VersionInfo ) )
		{
			VS_FIXEDFILEINFO* FixedFileInfo;

			UINT InfoLength = 0;
			if( VerQueryValue( VersionInfo, TEXT( "\\" ), ( void** )&FixedFileInfo, &InfoLength ) )
			{
				StringCchPrintf( StringBuffer, MaxSize, TEXT( "%d.%d.%d.%d" ), 
					HIWORD( FixedFileInfo->dwProductVersionMS ), LOWORD( FixedFileInfo->dwProductVersionMS ), HIWORD( FixedFileInfo->dwProductVersionLS ), LOWORD( FixedFileInfo->dwProductVersionLS ) );
			}
		}

		delete VersionInfo;
	}
}
Esempio n. 10
0
//=============================================================================
// 函数名称:	获得文件版本信息
// 作者说明:	mushuai
// 修改时间:	2010-03-08
//=============================================================================
CString GetFileVersion(LPCTSTR  FileName)  
{     
	int   iVerInfoSize;  
	char   *pBuf=0;  
	CString   asVer;  
	VS_FIXEDFILEINFO   *pVsInfo=0;  
	unsigned   int   iFileInfoSize   =   sizeof(VS_FIXEDFILEINFO);  
	iVerInfoSize   =   GetFileVersionInfoSize(FileName,NULL);   
	if(iVerInfoSize!= 0)  
	{     
		pBuf   =   new  char[iVerInfoSize];  
		if(GetFileVersionInfo(FileName,0,iVerInfoSize, pBuf))     
		{     
			if(VerQueryValue(pBuf,   _T("\\"),(void**)&pVsInfo,&iFileInfoSize))     
			{     
				asVer.Format(_T("%d.%d.%d.%d"),HIWORD(pVsInfo->dwFileVersionMS),
					LOWORD(pVsInfo->dwFileVersionMS),HIWORD(pVsInfo->dwFileVersionLS),
					LOWORD(pVsInfo->dwFileVersionLS));  
			}     
		}     
		delete   pBuf;     
	}     
	return   asVer;     
}
Esempio n. 11
0
int CCrashHandler::Init(
  LPCTSTR lpcszAppName,
  LPCTSTR lpcszAppVersion,
  LPCTSTR lpcszCrashSenderPath,
  LPGETLOGFILE lpfnCallback, 
  LPCTSTR lpcszTo, 
  LPCTSTR lpcszSubject,
  LPCTSTR lpcszUrl,
  UINT (*puPriorities)[5],
  DWORD dwFlags,
  LPCTSTR lpcszPrivacyPolicyURL)
{ 
  crSetErrorMsg(_T("Unspecified error."));
  
  // save user supplied callback
  if (lpfnCallback)
    m_lpfnCallback = lpfnCallback;

  // Get handle to the EXE module used to create this process
  HMODULE hExeModule = GetModuleHandle(NULL);
  if(hExeModule==NULL)
  {
    ATLASSERT(hExeModule!=NULL);
    crSetErrorMsg(_T("Couldn't get module handle for the executable."));
    return 1;
  }

  TCHAR szExeName[_MAX_PATH];
  DWORD dwLength = GetModuleFileName(hExeModule, szExeName, _MAX_PATH);  
  if(dwLength==0)
  {
    // Couldn't get the name of EXE that was used to create current process
    ATLASSERT(0);
    crSetErrorMsg(_T("Couldn't get the name of EXE that was used to create current process."));
    return 1;
  }  

  // Save EXE image name
  m_sImageName = CString(szExeName, dwLength);

  // Save application name
  m_sAppName = lpcszAppName;

  // If no app name provided, use the default (EXE name)
  if(m_sAppName.IsEmpty())
    m_sAppName = CUtility::getAppName();

  // Save app version
  m_sAppVersion = lpcszAppVersion;

  // If no app version provided, use the default (EXE product version)
  if(m_sAppVersion.IsEmpty())
  {
    DWORD dwBuffSize = GetFileVersionInfoSize(szExeName, 0);
    LPBYTE pBuff = new BYTE[dwBuffSize];
    
    if(0!=GetFileVersionInfo(szExeName, 0, dwBuffSize, pBuff))
    {
      VS_FIXEDFILEINFO* fi = NULL;
      UINT uLen = 0;
      VerQueryValue(pBuff, _T("\\"), (LPVOID*)&fi, &uLen);

      WORD dwVerMajor = (WORD)(fi->dwProductVersionMS>>16);
      WORD dwVerMinor = (WORD)(fi->dwProductVersionMS&0xFF);
      WORD dwPatchLevel = (WORD)(fi->dwProductVersionLS>>16);
      WORD dwVerBuild = (WORD)(fi->dwProductVersionLS&0xFF);

      m_sAppVersion.Format(_T("%u.%u.%u.%u"), 
        dwVerMajor, dwVerMinor, dwPatchLevel, dwVerBuild);
    }
Esempio n. 12
0
void LoadLangDll()
{
	if ((g_langid != g_ShellCache.GetLangID())&&((g_langTimeout == 0)||(g_langTimeout < GetTickCount())))
	{
		g_langid = g_ShellCache.GetLangID();
		DWORD langId = g_langid;
		TCHAR langDll[MAX_PATH*4];
		HINSTANCE hInst = NULL;
		TCHAR langdir[MAX_PATH] = {0};
		char langdirA[MAX_PATH] = {0};
		if (GetModuleFileName(g_hmodThisDll, langdir, _countof(langdir))==0)
			return;
		if (GetModuleFileNameA(g_hmodThisDll, langdirA, _countof(langdirA))==0)
			return;
		TCHAR * dirpoint = _tcsrchr(langdir, '\\');
		char * dirpointA = strrchr(langdirA, '\\');
		if (dirpoint)
			*dirpoint = 0;
		if (dirpointA)
			*dirpointA = 0;
		dirpoint = _tcsrchr(langdir, '\\');
		dirpointA = strrchr(langdirA, '\\');
		if (dirpoint)
			*dirpoint = 0;
		if (dirpointA)
			*dirpointA = 0;
		strcat_s(langdirA, "\\Languages");
//		bindtextdomain ("subversion", langdirA);

		BOOL bIsWow = FALSE;
		IsWow64Process(GetCurrentProcess(), &bIsWow);

		do
		{
			if (bIsWow)
				_stprintf_s(langDll, _T("%s\\Languages\\TortoiseProc32%lu.dll"), langdir, langId);
			else
				_stprintf_s(langDll, _T("%s\\Languages\\TortoiseProc%lu.dll"), langdir, langId);
			BOOL versionmatch = TRUE;

			struct TRANSARRAY
			{
				WORD wLanguageID;
				WORD wCharacterSet;
			};

			DWORD dwReserved,dwBufferSize;
			dwBufferSize = GetFileVersionInfoSize((LPTSTR)langDll,&dwReserved);

			if (dwBufferSize > 0)
			{
				LPVOID pBuffer = (void*) malloc(dwBufferSize);

				if (pBuffer != (void*) NULL)
				{
					UINT        nInfoSize = 0;
					UINT        nFixedLength = 0;
					LPSTR       lpVersion = NULL;
					VOID*       lpFixedPointer;
					TRANSARRAY* lpTransArray;
					TCHAR       strLangProductVersion[MAX_PATH];

					if (GetFileVersionInfo((LPTSTR)langDll,
						dwReserved,
						dwBufferSize,
						pBuffer))
					{
						// Query the current language
						if (VerQueryValue(	pBuffer,
							_T("\\VarFileInfo\\Translation"),
							&lpFixedPointer,
							&nFixedLength))
						{
							lpTransArray = (TRANSARRAY*) lpFixedPointer;

							_stprintf_s(strLangProductVersion, _T("\\StringFileInfo\\%04x%04x\\ProductVersion"),
								lpTransArray[0].wLanguageID, lpTransArray[0].wCharacterSet);

							if (VerQueryValue(pBuffer,
								(LPTSTR)strLangProductVersion,
								(LPVOID *)&lpVersion,
								&nInfoSize))
							{
								versionmatch = (_tcscmp((LPCTSTR)lpVersion, _T(STRPRODUCTVER)) == 0);
							}

						}
					}
					free(pBuffer);
				} // if (pBuffer != (void*) NULL)
			} // if (dwBufferSize > 0)
			else
				versionmatch = FALSE;

			if (versionmatch)
				hInst = LoadLibrary(langDll);
			if (hInst != NULL)
			{
				if (g_hResInst != g_hmodThisDll)
					FreeLibrary(g_hResInst);
				g_hResInst = hInst;
			}
			else
			{
				DWORD lid = SUBLANGID(langId);
				lid--;
				if (lid > 0)
				{
					langId = MAKELANGID(PRIMARYLANGID(langId), lid);
				}
				else
					langId = 0;
			}
		} while ((hInst == NULL) && (langId != 0));
		if (hInst == NULL)
		{
			// either the dll for the selected language is not present, or
			// it is the wrong version.
			// fall back to English and set a timeout so we don't retry
			// to load the language dll too often
			if (g_hResInst != g_hmodThisDll)
				FreeLibrary(g_hResInst);
			g_hResInst = g_hmodThisDll;
			g_langid = 1033;
			// set a timeout of 10 seconds
			if (g_ShellCache.GetLangID() != 1033)
				g_langTimeout = GetTickCount() + 10000;
		}
		else
			g_langTimeout = 0;
	} // if (g_langid != g_ShellCache.GetLangID())
}
Esempio n. 13
0
void SetVersion(LPCTSTR lpszFile)
{
    VS_VERSIONINFO		*pVerInfo;
    LPBYTE				pOffsetBytes;
    VS_FIXEDFILEINFO	*pFixedInfo;
    DWORD				dwHandle, dwSize, dwResult = 0;
    
    // determine the size of the resource information
    dwSize = GetFileVersionInfoSize((LPTSTR)lpszFile, &dwHandle);
    if (0 < dwSize)
    {
        LPBYTE lpBuffer = new BYTE[dwSize];
        
        if (GetFileVersionInfo((LPTSTR)lpszFile, 0, dwSize, lpBuffer) != FALSE)
        {
            // these macros help to align on r-byte boundaries (thanks Ted Peck)
            
            // 'point to' the start of the version information block
            pVerInfo = (VS_VERSIONINFO *) lpBuffer;
            
            // the fixed section starts right after the 'VS_VERSION_INFO' string
            pOffsetBytes = (BYTE *) &pVerInfo->szKey[wcslen(pVerInfo->szKey) + 1];
			
            pFixedInfo = (VS_FIXEDFILEINFO *) roundpos(pVerInfo, pOffsetBytes, 4);
			
            // increment the numbers!
            pFixedInfo->dwFileVersionMS    = pFixedInfo->dwFileVersionMS + 0x00010001;
            pFixedInfo->dwFileVersionLS    = pFixedInfo->dwFileVersionLS + 0x00010001;
            pFixedInfo->dwProductVersionMS = pFixedInfo->dwProductVersionMS + 0x00010001;
            pFixedInfo->dwProductVersionLS = pFixedInfo->dwProductVersionLS + 0x00010001;
			
            HANDLE hResource = BeginUpdateResource(lpszFile, FALSE);
            if (NULL != hResource)
            {
                UINT uTemp;
				
                // get the language information
                if (VerQueryValue(lpBuffer, _T("\\VarFileInfo\\Translation"), (LPVOID *) &lpTranslate, &uTemp) != FALSE)
                {
                    // could probably just use LANG_NEUTRAL/SUBLANG_NEUTRAL
                    if (UpdateResource(hResource, RT_VERSION, MAKEINTRESOURCE(VS_VERSION_INFO), lpTranslate->wLanguage, lpBuffer, dwSize) != FALSE)
                    {
                        if (EndUpdateResource(hResource, FALSE) == FALSE)
                            dwResult = GetLastError();
                    }
                    else
                        dwResult = GetLastError();
                }
            }
            else
                dwResult = GetLastError();
        }
        else
            dwResult = GetLastError();
		
        delete [] lpBuffer;
    }
    else
        dwResult = GetLastError();
	
	//if (0 != dwResult)
	//	wprintf(_T("Operation was not successful.  Result = %lu\n"), dwResult);
}
Esempio n. 14
0
INT
CompareVersion(char *FileName)
{
    DWORD	dwHandle = 0L;	/* Ignored in call to GetFileVersionInfo */
    DWORD	cbBuf = 0L;
    LPVOID	lpvData = NULL, lpValue = NULL, lpMsgBuf;
    UINT	wBytes = 0L;
    WORD	wlang = 0, wcset = 0;
    char	SubBlk[128];
    int		status = 0, majver = 0, minver = 0, relno = 0;
    CString	Message, Message2;

    /* Retrieve Size of Version Resource */
    if ((cbBuf = GetFileVersionInfoSize(FileName, &dwHandle)) == 0)
    {
	FormatMessage(  FORMAT_MESSAGE_ALLOCATE_BUFFER |
			FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL, GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
			(LPTSTR) &lpMsgBuf, 0, NULL );
	Message2.LoadString(IDS_TITLE);
	Message.LoadString(IDS_FAIL_VERS);
	Message += CString((LPTSTR)lpMsgBuf);
	MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
	LocalFree(lpMsgBuf);
	return 0;
    }

    lpvData = (LPVOID)malloc(cbBuf);
    if(!lpvData)
    {
	FormatMessage(  FORMAT_MESSAGE_ALLOCATE_BUFFER |
			FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL, GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
			(LPTSTR) &lpMsgBuf, 0, NULL );
	Message2.LoadString(IDS_TITLE);
	Message.LoadString(IDS_FAIL_VERS);
	Message += CString((LPTSTR)lpMsgBuf);
	MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
	LocalFree(lpMsgBuf);
	free(lpvData);
	return 0;
    }

    /* Retrieve Version Resource */
    if (GetFileVersionInfo(FileName, dwHandle, cbBuf, lpvData) == FALSE)
    {
	FormatMessage(  FORMAT_MESSAGE_ALLOCATE_BUFFER |
			FORMAT_MESSAGE_FROM_SYSTEM |
			FORMAT_MESSAGE_IGNORE_INSERTS,
			NULL, GetLastError(),
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
			(LPTSTR) &lpMsgBuf, 0, NULL );
	Message2.LoadString(IDS_TITLE);
	Message.LoadString(IDS_FAIL_VERS);
	Message += CString((LPTSTR)lpMsgBuf);
	MessageBox(NULL, Message, Message2, MB_OK | MB_ICONEXCLAMATION);
	LocalFree(lpMsgBuf);
	free(lpvData);
	return 0;
    }

    /* Retrieve the Language and Character Set Codes */
    VerQueryValue(lpvData, TEXT("\\VarFileInfo\\Translation"),
		  &lpValue, &wBytes);
    wlang = *((WORD *)lpValue);
    wcset = *(((WORD *)lpValue)+1);

    /* Retrieve ProductVersion Information */
    sprintf(SubBlk, "\\StringFileInfo\\%.4x%.4x\\ProductVersion",
	    wlang, wcset);
    VerQueryValue(lpvData, TEXT(SubBlk), &lpValue, &wBytes);
    sscanf((char *)lpValue, "%d.%d.%d", &majver, &minver, &relno);
    free(lpvData);

    /* Check Major Version Number, anything above 8.0 is
    ** acceptable.
    */
    if ((majver >= 8) )
	return 1;
    else
    {
	char	outstring[1024];

	Message.LoadString(IDS_VERSION_INCORRECT);
	Message2.LoadString(IDS_TITLE);
	sprintf(outstring, Message, majver, minver);
	MessageBox(NULL, outstring, Message2, MB_OK | MB_ICONEXCLAMATION);
	return 0;
    }
}
// Message handler for about box.
LRESULT CALLBACK VirtualDimension::About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
	static IPicture * picture;

	switch (message)
	{
	case WM_INITDIALOG:
		SetFocus(GetDlgItem(hDlg, IDOK));
		picture = PlatformHelper::OpenImage(MAKEINTRESOURCE(IDI_VIRTUALDIMENSION));

		TCHAR text[MAX_PATH];
		DWORD dwHandle;
		DWORD vinfSize;
		LPVOID lpVersionInfo;
		TCHAR * lpVal;
		UINT dwValSize;
		TCHAR * context;

		GetModuleFileName(NULL, text, MAX_PATH);
		vinfSize = GetFileVersionInfoSize(text, &dwHandle);
		lpVersionInfo = malloc(vinfSize);
		GetFileVersionInfo(text, dwHandle, vinfSize, lpVersionInfo);

		VerQueryValue(lpVersionInfo, TEXT("\\StringFileInfo\\040904b0\\ProductName"), (LPVOID*)&lpVal, &dwValSize);
		_tcsncpy_s(text, lpVal, dwValSize);
		_tcscat_s(text, TEXT(" v"));
		VerQueryValue(lpVersionInfo, TEXT("\\StringFileInfo\\040904b0\\ProductVersion"), (LPVOID*)&lpVal, &dwValSize);
		lpVal = _tcstok_s(lpVal, TEXT(", \t"), &context);
		_tcscat_s(text, lpVal);
		_tcscat_s(text, TEXT("."));
		lpVal = _tcstok_s(NULL, TEXT(", \t"), &context);
		_tcscat_s(text, lpVal);
		lpVal = _tcstok_s(NULL, TEXT(", \t"), &context);
		if (*lpVal != TEXT('0'))
		{
			*lpVal += TEXT('a') - TEXT('0');
			_tcscat_s(text, lpVal);
		}
		SetDlgItemText(hDlg, IDC_PRODUCT, text);

		VerQueryValue(lpVersionInfo, TEXT("\\StringFileInfo\\040904b0\\LegalCopyright"), (LPVOID*)&lpVal, &dwValSize);
		_tcsncpy_s(text, lpVal, dwValSize);
		SetDlgItemText(hDlg, IDC_COPYRIGHT, text);

		free(lpVersionInfo);
		return FALSE;

	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case IDOK:
		case IDCANCEL:
			EndDialog(hDlg, LOWORD(wParam));
			if (picture)
			{
				picture->Release();
				picture = NULL;
			}
			return TRUE;

		case IDC_HOMEPAGE_LINK:
			if (HIWORD(wParam) == STN_CLICKED)
			{
			 ShellExecute(hDlg, TEXT("open"), TEXT("http://virt-dimension.sourceforge.net"),
						  NULL, NULL, SW_SHOWNORMAL);
			}
			break;

		case IDC_GPL_LINK:
			if (HIWORD(wParam) == STN_CLICKED)
			{
			 ShellExecute(hDlg, TEXT("open"), TEXT("LICENSE.html"),
						  NULL, NULL, SW_SHOWNORMAL);
			}
			break;
		}
		break;

	case WM_DRAWITEM:
		if (picture)
			PlatformHelper::CustomDrawIPicture(picture, (LPDRAWITEMSTRUCT)lParam, false);
		return TRUE;
	}
	return FALSE;
}
Esempio n. 16
0
/**
 * Worker for VBoxServiceGetFileVersionString.
 *
 * @returns VBox status code.
 * @param   pszFilename         ASCII & ANSI & UTF-8 compliant name.
 */
static int VBoxServiceGetFileVersion(const char *pszFilename,
                                     PDWORD pdwMajor,
                                     PDWORD pdwMinor,
                                     PDWORD pdwBuildNumber,
                                     PDWORD pdwRevisionNumber)
{
    int rc;

    *pdwMajor = *pdwMinor = *pdwBuildNumber = *pdwRevisionNumber = 0;

    /*
     * Get the file version info.
     */
    DWORD dwHandleIgnored;
    DWORD cbVerData = GetFileVersionInfoSizeA(pszFilename, &dwHandleIgnored);
    if (cbVerData)
    {
        LPTSTR pVerData = (LPTSTR)RTMemTmpAllocZ(cbVerData);
        if (pVerData)
        {
            if (GetFileVersionInfoA(pszFilename, dwHandleIgnored, cbVerData, pVerData))
            {
                /*
                 * Try query and parse the FileVersion string our selves first
                 * since this will give us the correct revision number when
                 * it goes beyond the range of an uint16_t / WORD.
                 */
                if (VBoxServiceGetFileVersionOwn(pVerData, pdwMajor, pdwMinor, pdwBuildNumber, pdwRevisionNumber))
                    rc = VINF_SUCCESS;
                else
                {
                    /* Fall back on VS_FIXEDFILEINFO */
                    UINT                 cbFileInfoIgnored = 0;
                    VS_FIXEDFILEINFO    *pFileInfo = NULL;
                    if (VerQueryValue(pVerData, "\\", (LPVOID *)&pFileInfo, &cbFileInfoIgnored))
                    {
                        *pdwMajor          = HIWORD(pFileInfo->dwFileVersionMS);
                        *pdwMinor          = LOWORD(pFileInfo->dwFileVersionMS);
                        *pdwBuildNumber    = HIWORD(pFileInfo->dwFileVersionLS);
                        *pdwRevisionNumber = LOWORD(pFileInfo->dwFileVersionLS);
                        rc = VINF_SUCCESS;
                    }
                    else
                    {
                        rc = RTErrConvertFromWin32(GetLastError());
                        VBoxServiceVerbose(3, "No file version value for file \"%s\" available! (%d / rc=%Rrc)\n",
                                           pszFilename,  GetLastError(), rc);
                    }
                }
            }
            else
            {
                rc = RTErrConvertFromWin32(GetLastError());
                VBoxServiceVerbose(0, "GetFileVersionInfo(%s) -> %u / %Rrc\n", pszFilename, GetLastError(), rc);
            }

            RTMemTmpFree(pVerData);
        }
        else
        {
            VBoxServiceVerbose(0, "Failed to allocate %u byte for file version info for '%s'\n", cbVerData, pszFilename);
            rc = VERR_NO_TMP_MEMORY;
        }
    }
    else
    {
        rc = RTErrConvertFromWin32(GetLastError());
        VBoxServiceVerbose(3, "GetFileVersionInfoSize(%s) -> %u / %Rrc\n", pszFilename, GetLastError(), rc);
    }
    return rc;
}
Esempio n. 17
0
void ShowVersionInfo( PSTR pszFileName )
{
    DWORD cbVerInfo, dummy;

    // How big is the version info?
    cbVerInfo = GetFileVersionInfoSize( pszFileName, &dummy );
    if ( !cbVerInfo )
        return;

    // Allocate space to hold the info
    PBYTE pVerInfo = new BYTE[cbVerInfo];
    if ( !pVerInfo )
        return;

    _try
    {
        if ( !GetFileVersionInfo(pszFileName, 0, cbVerInfo, pVerInfo) )
            _leave;

        char * predefResStrings[] =
        {
            "CompanyName",
            "FileDescription",
            "FileVersion",
            "InternalName",
            "LegalCopyright",
            "OriginalFilename",
            "ProductName",
            "ProductVersion",
            0
        };

        for ( unsigned i=0; predefResStrings[i]; i++ )
        {
            char szQueryStr[ 0x100 ];
            char szQueryStr2[0x100 ];

            // Format the string with the 1200 codepage (Unicode)
            wsprintf( szQueryStr, "\\StringFileInfo\\%04X%04X\\%s",
                      GetUserDefaultLangID(), 1200,
                      predefResStrings[i] );

            // Format the string with the 1252 codepage (Windows Multilingual)
            wsprintf( szQueryStr2, "\\StringFileInfo\\%04X%04X\\%s",
                      GetUserDefaultLangID(), 1252,
                      predefResStrings[i] );
            // We may want to format a string with the "0000" codepage

            PSTR pszVerRetVal;
            UINT cbReturn;
            BOOL fFound;

            // Try first with the 1252 codepage
            fFound = VerQueryValue( pVerInfo, szQueryStr,
                                    (LPVOID *)&pszVerRetVal, &cbReturn );
            if ( !fFound )
            {
                // Hmm... 1252 wasn't found.  Try the 1200 codepage
                fFound = VerQueryValue( pVerInfo, szQueryStr2,
                                        (LPVOID *)&pszVerRetVal, &cbReturn );
            }

            if ( fFound )
                printf( "  %s %s\n", predefResStrings[i], pszVerRetVal );
        }
    }
    _finally
    {
        delete []pVerInfo;
    }
}
Esempio n. 18
0
/*
** Get a temporary file name
**
** Can pass in Dir to use instead of %TEMP%
** Can pass in prefix to use instead of NCS
** Can pass in file extension to use instead of .tmp
*/
char *NCSGetTempFileName(char *pDir,
						 char *pPrefix,
						 char *pExt)
{
	char *pTmpName = NULL;

#if defined PALM

	return(NULL);

#else	/* MACINTOSH */
	
    char buf[MAX_PATH];

    if(pDir == (char *)NULL || (pDir && strlen(pDir) == 0)) {
		pDir = NCSGetTempDirectory();
    } else {
		pDir = NCSStrDup(pDir);
	}
	if(pExt == NULL) {
		pExt = ".tmp";
	}
	if(pPrefix == NULL) {
		pPrefix = "NCS";
	}

#ifdef WIN32
	{
		int i = 0;
#ifndef _WIN32_WCE
		srand( (unsigned)time( NULL ) );
#endif	
		while(i < 65535) {
			sprintf(buf, "%s\\%s%lx%lx%s", pDir, pPrefix, rand(), rand(), pExt);
#if defined(_WIN32_WCE)||defined(NCS_MINDEP_BUILD)
			if(NCSFileSizeBytes(buf) < 0) {
#else
			if(PathFileExistsA(buf) == FALSE) {
#endif
				pTmpName = NCSStrDup(buf);
				break;
			} 
			i++;
		}
	}
	NCSFree((void*)pDir);
	
#elif defined( MACOSX )
    sprintf(buf, "%sXXXXXX", pPrefix ? pPrefix : "NCS");

    pTmpName = NCSMalloc(strlen(pDir) + strlen(buf) + strlen(pExt) + 3, FALSE);
    sprintf(pTmpName, "%s/%s", pDir, buf);

    mktemp(pTmpName);

    NCSFree((void*)pDir);
    strcat(pTmpName, pExt);	// FIXME: Is this really going to be unique?

#else

	sprintf(buf, "%sXXXXXX", pPrefix ? pPrefix : "NCS");

	pTmpName = NCSMalloc(strlen(pDir) + strlen(buf) + strlen(pExt) + 3, FALSE);
	sprintf(pTmpName, "%s/%s", pDir, buf);

    mktemp(pTmpName);

	NCSFree((void*)pDir);
	strcat(pTmpName, pExt);	// FIXME: Is this really going to be unique?

#endif
#endif

    return(pTmpName);
}

/*
** Get name of temp directory
**
** WIN32:
** Default: %TEMP% env variable
** 9x:		C:\Windows\Temp
** NT:		C:\Temp
** CE:		\Temp
*/
char *NCSGetTempDirectory(void)
{
#ifdef _WIN32_WCE

	return(NCSStrDup("\\Temp"));

#elif defined WIN32

	NCSTChar winbuf[MAX_PATH];

	if(GetTempPath((DWORD)MAX_PATH, winbuf) == 0) {
		if(GetSystemDirectory(winbuf, MAX_PATH)) {
			if(NCSGetPlatform() == NCS_WINDOWS_NT) {
				/* eg, c:\Temp */
				winbuf[3] = '\0';
				NCSTCat(winbuf, NCS_T("Temp"));
			} else {
				/* eg, c:\Windows\Temp */
				NCSTCat(winbuf, NCS_T("Temp"));
			}
		}
	}
	if((winbuf[0] != '\0') && (winbuf[NCSTLen(winbuf) - 1] == '\\')) {
		winbuf[NCSTLen(winbuf) - 1] = '\0';
	}
	return(NCSStrDup(CHAR_STRING(winbuf)));

#elif defined PALM

	return(NCSStrDup(""));

#elif defined MACOSX

        FSRef tempRef;
        UInt8 szPath[1024] = "";
        
        
        if( FSFindFolder( kUserDomain, kTemporaryFolderType, kDontCreateFolder, &tempRef ) == noErr ) {
            if( FSRefMakePath( &tempRef, szPath, 1024 ) == noErr ) {
            }
        }
         

        return( NCSStrDup(szPath) );

#elif defined POSIX

	return(NCSStrDup("/tmp"));

#else	/* PALM */
	char *szTmpDir = getenv("TMP");
	if (szTmpDir != NULL)
		return NCSStrDup(szTmpDir);
	else return NCSStrDup("/tmp");

#endif
}

/*
** Get File Version information [01]
**
*/
BOOLEAN NCSFileGetVersion(char *pFileName,
						  UINT16 *pMajor,
						  UINT16 *pMinor,
						  UINT16 *pRevision,
						  UINT16 *pBuild)
{
	BOOLEAN bRVal = FALSE;

	if(pFileName) {
#if defined(_WIN32_WCE)||defined(NCS_MINDEP_BUILD)

	return(FALSE);

#elif defined WIN32
		DWORD dwVISize;
		DWORD dwZero;

		dwVISize = GetFileVersionInfoSize(OS_STRING(pFileName), &dwZero);

		if(dwVISize != 0) {
			LPVOID lpData = NCSMalloc(dwVISize, TRUE);

			if(lpData) {
				if(GetFileVersionInfo(OS_STRING(pFileName),
									  0,
									  dwVISize,
									  lpData)) {
					VS_FIXEDFILEINFO *pVI = (VS_FIXEDFILEINFO*)NULL;
					UINT dwSize;

					if(VerQueryValue(lpData, 
									 NCS_T("\\"), 
									 (LPVOID*)&pVI,
									 &dwSize) && pVI) {
				
						if(pMajor) {
							*pMajor = (UINT16)(pVI->dwFileVersionMS >> 16);
						}
						if(pMinor) {
							*pMinor = (UINT16)(pVI->dwFileVersionMS & 0xffff);
						}
						if(pRevision) {
							*pRevision = (UINT16)(pVI->dwFileVersionLS >> 16);
						}
						if(pBuild) {
							*pBuild = (UINT16)(pVI->dwFileVersionLS & 0xffff);
						}
						bRVal = TRUE;
					}
				}
				NCSFree(lpData);
			}
		}
Esempio n. 19
0
int
main (int argc, char **argv)
{
  unsigned int new_v[4];
  int update_version = 0;
  DWORD version_info_size;
  DWORD dummy;
  unsigned char *buffer;
  VS_FIXEDFILEINFO *fixed_file_info;
  UINT fixed_file_info_len;

  if (argc == 4 &&
      strcmp (argv[1], "-s") == 0)
    {
      int i;

      if (sscanf (argv[2], "%u.%u.%u.%u",
		  &new_v[0],
		  &new_v[1],
		  &new_v[2],
		  &new_v[3]) != 4)
	{
	  fprintf (stderr, "Wrong new version format.\n");
	  exit (1);
	}

      for (i = 0; i < 4; i++)
	if (new_v[i] > 0xFFFF)
	  {
	    fprintf (stderr, "Wrong new version format.\n");
	    exit (1);
	  }

      update_version = 1;
      argc -= 2;
      argv += 2;
    }

  if (argc != 2)
    {
      fprintf (stderr, "Usage: fileversion [ -s a.b.c.d ] file\n");
      exit (1);
    }

  version_info_size = GetFileVersionInfoSize (argv[1], &dummy);

  buffer = malloc (version_info_size);

  if (!GetFileVersionInfo (argv[1], 0, version_info_size, buffer))
    {
      if (update_version)
	fprintf (stderr, "GetFileVersionInfo() failed, file probably lacks a version resource block.\n");
      exit (1);
    }

  if (!VerQueryValue (buffer, "\\", (LPVOID*) &fixed_file_info, &fixed_file_info_len))
    {
      if (update_version)
	fprintf (stderr, "VerQueryValue() failed.\n");
      exit (1);
    }

  if (fixed_file_info_len < sizeof (*fixed_file_info))
    {
      if (update_version)
	fprintf (stderr, "Too small size VS_FIXEDFILEINFO.\n");
      exit (1);
    }

  if (update_version)
    {
      HANDLE resource;

      fixed_file_info->dwFileVersionMS = 0x10000 * new_v[0] + new_v[1];
      fixed_file_info->dwFileVersionLS = 0x10000 * new_v[2] + new_v[3];
      
      if (!(resource = BeginUpdateResource (argv[1], FALSE)))
	{
	  fprintf (stderr, "BeginUpdateResource() failed.\n");
	  exit (1);
	}
      if (!UpdateResource (resource,
			   RT_VERSION,
			   MAKEINTRESOURCE (VS_VERSION_INFO),
			   MAKELANGID (LANG_NEUTRAL, SUBLANG_NEUTRAL),
			   buffer,
			   version_info_size))
	{
	  fprintf (stderr, "UpdateResource() failed.\n");
	  exit (1);
	}
      if (!EndUpdateResource (resource, FALSE))
	{
	  fprintf (stderr, "EndUpdateResource() failed.\n");
	  exit (1);
	}
    }
  else
    printf ("%d.%d.%d.%d\n",
	    HIWORD (fixed_file_info->dwFileVersionMS),
	    LOWORD (fixed_file_info->dwFileVersionMS),
	    HIWORD (fixed_file_info->dwFileVersionLS),
	    LOWORD (fixed_file_info->dwFileVersionLS));

  exit (0);
}
/**********************************************************************
* ComponentVersionsDlgProc *
*--------------------------*
*   Description:  
*       The DlgProc for the ComponentVersions dlg. It fills the edit
*       control with the version & path info of all the .dll's & .exe's
*       that are loaded by the app that is using us. 
*
*       If you wish to have other .dll's & .exe's included, then just
*       add their names to the s_aszModules_c array.  The rest happens
*       automatically.
*
*   Return:
*       TRUE if have processed the message
*       FALSE otherwise
**********************************************************************/
LRESULT CALLBACK ComponentVersionsDlgProc( HWND hDlg, UINT uiMessage, WPARAM wParam, LPARAM lParam )
{
    //--- basic dlg proc switch statement
    switch( uiMessage )
    {
        case WM_INITDIALOG:
			{
                //--- this array contains the full list of .dll's & .exe's that we will interogate.
                //    just add to this list when you want to add another module to the output
                static const LPCTSTR s_aszModules_c[] = 
                {
                    _T("dictpad.exe"),
                    _T("reco.exe"),
                    _T("speak.exe"),
                    _T("sapi.cpl"),
                    _T("srsvr.exe"),
                    _T("ttshello.exe"),
                    _T("wavtotext.exe"),
                    _T("wintts.exe"),
                    _T("sapi.dll"),
                    _T("spttseng.dll"),
                    _T("spcwfe.DLL"),
                    _T("spsreng.DLL"),
                    _T("spsr.DLL"),
                    _T("spsrx.DLL"),
                    _T("gramcomp.dll"),
                    _T("Lexicon.dll"),
                    _T("advapi32.DLL"),
                    _T("atl.DLL"),
                    _T("comctl32.DLL"),
                    _T("gdi32.DLL"),
                    _T("icap.DLL"),	
                    _T("kernel32.DLL"),
                    _T("lz32.DLL"),
                    _T("mfc42.DLL"),	
                    _T("mfc42d.DLL"),	
                    _T("mfc42u.DLL"),	
                    _T("mfc42ud.DLL"),
                    _T("msasm32.DLL"),
                    _T("msvcrt.DLL"),
                    _T("msxml.DLL"),
                    _T("ntdll.DLL"),
                    _T("ole32.DLL"),
                    _T("oleaut32.DLL"),
                    _T("riched32.DLL"),
                    _T("rpcrt.DLL"),
                    _T("rpcrt4.DLL"),
                    _T("shell32.DLL"),
                    _T("shfolder.DLL"),
                    _T("shlwapi.DLL"),
                    _T("user32.DLL"),
                    _T("urlmon.DLL"),
                    _T("version.DLL"),
                    _T("winmm.DLL")
                };
                static const int s_iNumModules_c = sizeof( s_aszModules_c ) / sizeof( s_aszModules_c[ 0 ] );

                TCHAR acFinalBuff[10000];   
                acFinalBuff[ 0 ] = L'\0';

                //--- spin thru all the listed modules to find the ones that are loaded by the current app
                for( int i = 0;  i < s_iNumModules_c;  ++i )
                {
                    //--- main discovery point - is the current module being used, or not
			        HMODULE hModule = GetModuleHandle( s_aszModules_c[ i ] );
			        if( hModule )
			        {
                        //--- the current module is being used, get it's path
				        TCHAR acModulePath[ _MAX_PATH ];
				        DWORD dwSize = GetModuleFileName( hModule, acModulePath, sizeof( acModulePath ) );
				        _ASSERTE( 0 < dwSize );

                        //--- now that we have the file, get the version info size from that file.  If the 
                        //    size is non-trivial, then the file contains legitimate version info
				        DWORD dwDummy;
				        dwSize = GetFileVersionInfoSize( const_cast< LPTSTR >( acModulePath ), &dwDummy );
			            TCHAR acBuff[1000];  
				        if( 0 < dwSize )
                        {
                            //--- real version info exists for the current module - get it
				            char *pcVersionInfo = new char[ dwSize ];
				            _ASSERTE( NULL != pcVersionInfo );
				            BOOL fSuccess = GetFileVersionInfo( const_cast< LPTSTR >( acModulePath ), 
                                                                0, dwSize, pcVersionInfo );
				            _ASSERTE( fSuccess );

                            //--- now convert the version info into something intelligible
				            VS_FIXEDFILEINFO	*pFixedVersionInfo;
				            UINT				uiFixedVersionSize;
				            fSuccess = VerQueryValue( pcVersionInfo, _T( "\\" ), 
										              reinterpret_cast< LPVOID * >( &pFixedVersionInfo ), 
										              &uiFixedVersionSize );
				            _ASSERTE( fSuccess );

				            //--- esnure we have a correct structure version!
				            _ASSERTE( uiFixedVersionSize == sizeof( VS_FIXEDFILEINFO ) );

                            //--- format the module name, version info & module path all nice and pretty
				            _stprintf( acBuff, _T( "%-15.15s: %3d.%02d.%02d.%04d   %s\r\n" ), 
                                s_aszModules_c[ i ],
					            HIWORD( pFixedVersionInfo->dwProductVersionMS ), 
					            LOWORD( pFixedVersionInfo->dwProductVersionMS ),
					            HIWORD( pFixedVersionInfo->dwProductVersionLS ), 
					            LOWORD( pFixedVersionInfo->dwProductVersionLS ),
                                acModulePath );
       				        
                            //--- clean-up
                            delete [] pcVersionInfo;
                        }
                        else
                        {
                            //--- no version info, but the module itself, as well as it's path, are still interesting
                            //    to know
                            _stprintf( acBuff, _T( "%-15.15s: <no version info>   %s\r\n" ), 
                                s_aszModules_c[ i ],
                                acModulePath );
                        }

                        //--- accummulate all the info in a single buffer 
                        if( ( _tcslen( acFinalBuff ) + _tcslen( acBuff ) ) < ( sizeof( acFinalBuff ) - 1 ) )
                        {
                            //--- plenty of room
                            _tcscat( acFinalBuff, acBuff );
                        }
                        else
                        {
                            //--- we just escaped a buffer overflow...
                            _tcscpy( acFinalBuff, _T( "<buffer too small>" ) );
                            break;
                        }
			        }
                }

                //--- send the fully populated buffer to the edit control
                HWND hEdit = ::GetDlgItem( hDlg, IDC_VERSION_EDIT );
                ::SetWindowText( hEdit, acFinalBuff );
            }
            return TRUE;

        case WM_SIZE:
            {
                //--- as the dlg resizes, have the edit control follow the client area's size
                RECT rect;
                ::GetClientRect( hDlg, &rect );
                HWND hEdit = ::GetDlgItem( hDlg, IDC_VERSION_EDIT );
                ::SetWindowPos( hEdit, NULL, rect.left, rect.top, 
                                LOWORD(lParam), HIWORD(lParam), SWP_NOZORDER | SWP_NOACTIVATE );
            }
            return TRUE;

        case WM_COMMAND:
            //--- kill the dialog when we get canceled by the user
            if( IDCANCEL == LOWORD( wParam ) )
            {
                EndDialog( hDlg, LOWORD( wParam ));
                return TRUE;
            }
            break;
    }

    //--- we didn't process this msg, let the default behavior prevail
    return FALSE;

} /* ComponentVersions */
Esempio n. 21
0
static void	MyGetEnvironmentInfo (void)
{
    static FilePath	stMyApplicationPath;
    static DWORD	stMyDummy;
    static DWORD	stMyVersionSize;
    static char		*stMyVersionInfo;
    static UINT		stMyVersionInfoSize;
    static char		stMyTempString [256];
    static HANDLE	stMyFile;
    static DWORD	stMyFileSize;
    static FILETIME	stMyFileTime, stMyDummy1, stMyDummy2;
    static SYSTEMTIME	stMySystemTime;
    	
    //
    // Line 1: Date: Oct 20, 2000
    //
    
    // Start with current date label
    MyAddToBuffer ("Date: ");

    // Add the current date
    GetDateFormat (LOCALE_USER_DEFAULT, 0, NULL, "MMM d yyyy", 
        stMyTempString, sizeof (stMyTempString));
    MyAddToBuffer (stMyTempString);

    // Add a space
    MyAddToBuffer (" ");
    
    // Add the current time    
    GetTimeFormat (LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, 
        stMyTempString, sizeof (stMyTempString));
    MyAddToBuffer (stMyTempString);
    
    // Add a newline
    MyAddToBuffer ("\r\n\r\n");
    
    //
    // Line 2: File Name: d:\ready\ready.exe
    //
    
    // Start with file name label
    MyAddToBuffer ("File Name: ");

    // Add the application path
    GetModuleFileName (NULL, stMyApplicationPath, sizeof (stMyApplicationPath));
    MyAddToBuffer (stMyApplicationPath);

    // Add a newline
    MyAddToBuffer ("\r\n");
    
    //
    // Line 3 (Maybe): Version: 1.0.2  [Mini/Restricted/IBM/71]
    //

    // Start with the version label
    MyAddToBuffer ("Version: ");
    
    // Set to empty string by default
    stMyVersionSize = GetFileVersionInfoSize (stMyApplicationPath, &stMyDummy);
    if ((stMyVersionSize != 0) && (stMyVersionSize <= stCrashBufferLeft))
    {
	if (GetFileVersionInfo (stMyApplicationPath, stMyDummy, 
				stCrashBufferLeft, stCrashBufferPtr))
	{
	    if (VerQueryValue (stCrashBufferPtr, 
			    "\\StringFileInfo\\04090000\\ProductVersion", 
			    &stMyVersionInfo, &stMyVersionInfoSize))
	    {			    
		// Add the version number (size includes \0)
		memmove (stCrashBufferPtr, stMyVersionInfo, 
			 stMyVersionInfoSize);
		stCrashBufferLeft -= stMyVersionInfoSize - 1;
		stCrashBufferPtr += stMyVersionInfoSize - 1; 
	    }
	    else
	    {
	    	MyAddToBuffer ("Unknown");
	    }
	}
	else
	{
	    MyAddToBuffer ("Unknown");
	}
    }
    else
    {
    	MyAddToBuffer ("Unknown");
    }
    
    if (gProgram.globalsInitialized)
    {
	// Add a spaces
	MyAddToBuffer ("  [");

	if (gProgram.miniVersion)
            MyAddToBuffer ("Mini/");
	if (gProgram.restrictedVersion)
            MyAddToBuffer ("Restricted/");
	if (gProgram.assistedByIBM)
            MyAddToBuffer ("IBM/");

	if (gProgram.expiryDateString [0] != 0)
	{
            MyAddToBuffer (gProgram.expiryDateString);
            MyAddToBuffer ("/");
	}

	wsprintf (stMyTempString, "%d]", gProgram.installKind);										    					        
        MyAddToBuffer (stMyTempString);
    } // if (gProgram.globalsInitialized)
		    
    // Add a newline
    MyAddToBuffer ("\r\n");
    
    //
    // Line 4: File Size: 2876346
    //
    stMyFile = CreateFile (stMyApplicationPath, GENERIC_READ, FILE_SHARE_READ,
                         NULL, OPEN_EXISTING, 0, 0);
    if (stMyFile != (HANDLE) INVALID_HANDLE_VALUE)
    {
    	stMyFileSize = GetFileSize (stMyFile, NULL);

    	// Start with the size label
	MyAddToBuffer ("File Size: ");
    
	// Add the file size
	wsprintf (stMyTempString, "%d\r\n", stMyFileSize);
	MyAddToBuffer (stMyTempString);
    	
    	//
    	// Line 5: File Date: Oct 10, 2000
    	//
    	GetFileTime (stMyFile, &stMyDummy1, &stMyDummy2, &stMyFileTime);
	if (FileTimeToSystemTime (&stMyFileTime, &stMySystemTime))
	{
    	    // Start with the date label
	    MyAddToBuffer ("File Date: ");
    
	    // Add the file date
	    GetDateFormat (LOCALE_USER_DEFAULT, 0, &stMySystemTime, 
	    	"MMM d yyyy", stMyTempString, sizeof (stMyTempString));
	    MyAddToBuffer (stMyTempString);
	    MyAddToBuffer (" ");
    	
	    // Add the file time
	    GetTimeFormat (LOCALE_USER_DEFAULT, TIME_NOSECONDS, &stMySystemTime, 
	        NULL, stMyTempString, sizeof (stMyTempString));
	    MyAddToBuffer (stMyTempString);
	}
	
	CloseHandle (stMyFile);
    }
    
    //
    // Line 6: Operating System: Windows 95
    //
    MyAddToBuffer ("\r\nOperating System: ");
    switch (gProgram.operatingSystem)
    {
    	case UNKNOWN_OS:
    	    MyAddToBuffer ("Unknown Windows version\r\n");
    	    break;
    	case WIN_95:
    	    MyAddToBuffer ("Windows 95\r\n");
    	    break;
	case WIN_95_OSR2:
    	    MyAddToBuffer ("Windows 95 Service Pack 2\r\n");
    	    break;
	case WIN_98:
    	    MyAddToBuffer ("Windows 98\r\n");
    	    break;
	case WIN_98_SE:
    	    MyAddToBuffer ("Windows 98 Second Edition\r\n");
    	    break;
	case WIN_ME:
    	    MyAddToBuffer ("Windows Me\r\n");
    	    break;
	case WIN_NT:
    	    MyAddToBuffer ("Windows NT\r\n");
    	    break;
	case WIN_2000:
    	    MyAddToBuffer ("Windows 2000\r\n");
    	    break;
	case WIN_XP:
    	    MyAddToBuffer ("Windows XP\r\n");
    	    break;
	case WIN_NEWER:
    	    MyAddToBuffer ("After Windows XP\r\n");
    	    break;
    	default:
    	    MyAddToBuffer ("Bad OS Value (%d)\r\n", gProgram.operatingSystem);
    	    break;
    	
    } // switch
    
    // 
    // Line 7: JVM: Ready Built-in JRE (1.4.2 or later)
    //
    MyAddToBuffer ("JVM: ");
    switch (gProperties.JVMType)
    {
	case JRE_131:
	    MyAddToBuffer ("Ready JRE 1.3.1\r\n");
	    break;
	case JRE_BUILT_IN:
	    MyAddToBuffer ("Ready Built-in JRE (1.4.2 or later)\r\n");
	    break;
	case JRE_IN_JRE_DIR:
	    MyAddToBuffer ("Ready User-installed JRE\r\n");
	    break;
	case JDK_IN_JRE_DIR:
	    MyAddToBuffer ("Ready User-installed JDK\r\n");
	    break;
	case JRE_IN_REGISTRY:
	    MyAddToBuffer ("Ready System JRE\r\n");
	    break;
	case JDK_IN_REGISTRY:
	    MyAddToBuffer ("Ready System JDK\r\n");
	    break;
    } // switch            
    
    // 
    // Line 8: "assert": enabled
    //
    if (gProperties.oldJavaCompile)
    {
    	MyAddToBuffer ("\"assert\" Statements: disabled\r\n");
    }
    else
    {
    	MyAddToBuffer ("\"assert\" Statements: enabled\r\n");
    }    	
} // MyGetEnvironmentInfo
Esempio n. 22
0
MEXP(int) getExeInfo(const char* file_name, char* exe_info,
					 size_t exe_info_size, uint32_t* version, int platform)
{
	const char* base = (char*) 0;
	unsigned long file_size;
	FILE* f = (FILE*) 0;
	int ret;
#ifdef MOS_WINDOWS
	HANDLE hFile;
	FILETIME ft;
	SYSTEMTIME st;
	LPBYTE buf;
	VS_FIXEDFILEINFO* ffi;
	DWORD infoSize, bytesRead;
#else
	cm_pe_t pe;
	cm_pe_resdir_t* root;
	cm_pe_resdir_t* dir;
	cm_pe_version_t ffi;
	size_t i;
	struct stat st;
	struct tm* time;
#endif
	
	if (!file_name || !exe_info || !exe_info_size || !version)
		return 0;

	base = basename(file_name);

	switch (platform) {
		case BNCSUTIL_PLATFORM_X86:
#ifdef MOS_WINDOWS				
			infoSize = GetFileVersionInfoSize(file_name, &bytesRead);
			if (infoSize == 0)
				return 0;
			buf = (LPBYTE) VirtualAlloc(NULL, infoSize, MEM_COMMIT,
										PAGE_READWRITE);
			if (buf == NULL)
				return 0;
			if (GetFileVersionInfo(file_name, NULL, infoSize, buf) == FALSE)
				return 0;
			if (!VerQueryValue(buf, "\\", (LPVOID*) &ffi, (PUINT) &infoSize))
				return 0;
			
			*version =
				((HIWORD(ffi->dwProductVersionMS) & 0xFF) << 24) |
				((LOWORD(ffi->dwProductVersionMS) & 0xFF) << 16) |
				((HIWORD(ffi->dwProductVersionLS) & 0xFF) << 8) | 
				(LOWORD(ffi->dwProductVersionLS) & 0xFF);
#if DEBUG
			bncsutil_debug_message_a("%s version = %d.%d.%d.%d (0x%08X)",
				base, (HIWORD(ffi->dwProductVersionMS) & 0xFF),
				(LOWORD(ffi->dwProductVersionMS) & 0xFF),
				(HIWORD(ffi->dwProductVersionLS) & 0xFF),
				(LOWORD(ffi->dwProductVersionLS) & 0xFF),
				*version);
#endif
			VirtualFree(buf, 0lu, MEM_RELEASE);
#else
			pe = cm_pe_load(file_name);
			if (!pe)
				return 0;
			root = cm_pe_load_resources(pe);
			if (!root) {
				cm_pe_unload(pe);
				return 0;
			}
				
			for (i = 0; i < root->subdir_count; i++) {
				dir = (root->subdirs + i);
				if (dir->name == 16) {
					if (!cm_pe_fixed_version(pe, dir->subdirs->resources,
											 &ffi))
					{
						cm_pe_unload_resources(root);
						cm_pe_unload(pe);
						return 0;
					}
					break;
				}
			}
			*version =
				((HIWORD(ffi.dwProductVersionMS) & 0xFF) << 24) |
				((LOWORD(ffi.dwProductVersionMS) & 0xFF) << 16) |
				((HIWORD(ffi.dwProductVersionLS) & 0xFF) << 8) | 
				(LOWORD(ffi.dwProductVersionLS) & 0xFF);
#if DEBUG
			bncsutil_debug_message_a("%s version = %d.%d.%d.%d (0x%08X)",
				base, (HIWORD(ffi.dwProductVersionMS) & 0xFF),
				(LOWORD(ffi.dwProductVersionMS) & 0xFF),
				(HIWORD(ffi.dwProductVersionLS) & 0xFF),
				(LOWORD(ffi.dwProductVersionLS) & 0xFF),
				*version);
#endif
			
			cm_pe_unload_resources(root);
			cm_pe_unload(pe);
#endif
			break;
		case BNCSUTIL_PLATFORM_MAC:
		case BNCSUTIL_PLATFORM_OSX:
			f = fopen(file_name, "r");
			if (!f)
				return 0;
			if (fseek(f, -4, SEEK_END) != 0) {
				fclose(f);
				return 0;
			}
			if (fread(version, 4, 1, f) != 1) {
				fclose(f);
				return 0;
			}
#ifdef MOS_WINDOWS
			fclose(f);
#endif
	}
	
#ifdef MOS_WINDOWS
	hFile = CreateFile(file_name, GENERIC_READ, FILE_SHARE_READ, NULL,
					   OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hFile == INVALID_HANDLE_VALUE)
		return 0;
	file_size = GetFileSize(hFile, NULL);
	if (!GetFileTime(hFile, &ft, NULL, NULL)) {
		CloseHandle(hFile);
		return 0;
	}
	
	if (!FileTimeToSystemTime(&ft, &st)) {
		CloseHandle(hFile);
		return 0;
	}
	CloseHandle(hFile);
	
	ret = snprintf(exe_info, exe_info_size,
				   "%s %02u/%02u/%02u %02u:%02u:%02u %lu", base, st.wMonth,
				   st.wDay, (st.wYear % 100), st.wHour, st.wMinute, st.wSecond,
				   file_size);

#else
	if (!f)
		f = fopen(file_name, "r");
	if (!f)
		return 0;
	if (fseek(f, 0, SEEK_END) == -1) {
		fclose(f);
		return 0;
	}
	file_size = ftell(f);
	fclose(f);
	
	if (stat(file_name, &st) != 0)
		return 0;
	
	time = gmtime(&st.st_mtime);
	if (!time)
		return 0;
	
	switch (platform) {
		case BNCSUTIL_PLATFORM_MAC:
		case BNCSUTIL_PLATFORM_OSX:
			if (time->tm_year >= 100) // y2k
				time->tm_year -= 100;
			break;
	}
	
	ret = (int) snprintf(exe_info, exe_info_size,
						"%s %02u/%02u/%02u %02u:%02u:%02u %lu", base, 
						(time->tm_mon+1), time->tm_mday, time->tm_year,
						time->tm_hour, time->tm_min, time->tm_sec, file_size);
#endif

#if DEBUG
	bncsutil_debug_message(exe_info);
#endif

	return ret;
}
Esempio n. 23
0
void print_version_info(char *progname)
{
    DWORD dummy, infosize;

    if (!(infosize = GetFileVersionInfoSize(progname, &dummy)))
      {
          puts("(no version info)");
          return;
      }
    else
      {
          void *info = malloc(infosize);
          VS_FIXEDFILEINFO *fixed_info;
          UINT fixed_len;

          if (!info)
            {
                puts("(error on malloc");
                return;
            }

          GetFileVersionInfo(progname, 0, infosize, info);
          VerQueryValue(info, "\\", &fixed_info, &fixed_len);

          /* File Version */
          printf("File Version:    %d.%d.%d.%d\n",
                 HIWORD(fixed_info->dwFileVersionMS),
                 LOWORD(fixed_info->dwFileVersionMS),
                 HIWORD(fixed_info->dwFileVersionLS),
                 LOWORD(fixed_info->dwFileVersionLS));

          /* Product Version */
          printf("Product Version: %d.%d.%d.%d\n",
                 HIWORD(fixed_info->dwProductVersionMS),
                 LOWORD(fixed_info->dwProductVersionMS),
                 HIWORD(fixed_info->dwProductVersionLS),
                 LOWORD(fixed_info->dwProductVersionLS));

          {                     /* File Flags */
              DWORD flags = fixed_info->dwFileFlags & fixed_info->dwFileFlagsMask;
              fputs("Flags:           ", stdout);
              if (!flags)
                  fputs("(none)", stdout);
              if (flags & VS_FF_DEBUG)
                  fputs("Debug ", stdout);
              if (flags & VS_FF_PRERELEASE)
                  fputs("Prerelease ", stdout);
              if (flags & VS_FF_PATCHED)
                  fputs("Patched ", stdout);
              if (flags & VS_FF_PRIVATEBUILD)
                  fputs("PrivateBuild ", stdout);
              if (flags & VS_FF_INFOINFERRED)
                  fputs("InfoInferred ", stdout);
              if (flags & VS_FF_SPECIALBUILD)
                  fputs("SpecialBuild ", stdout);
              putchar('\n');
          }

          {                     /* File OS. */
              fputs("OS:              ", stdout);
              switch (LOWORD(fixed_info->dwFileOS))
                {
                    case VOS__WINDOWS16:
                        fputs("16-Bit Windows", stdout);
                        break;
                    case VOS__PM16:
                        fputs("16-Bit Presentation Manager", stdout);
                        break;
                    case VOS__PM32:
                        fputs("32-Bit Presentation Manager", stdout);
                        break;
                    case VOS__WINDOWS32:
                        fputs("Win32", stdout);
                        break;
                    default:
                        fputs("(unknown)", stdout);
                        break;
                }
              fputs(" on ", stdout);
              switch (MAKELONG(0, HIWORD(fixed_info->dwFileOS)))
                {
                    case VOS_DOS:
                        puts("MS-DOS");
                        break;
                    case VOS_OS216:
                        puts("16-Bit OS/2");
                        break;
                    case VOS_OS232:
                        puts("32-Bit OS/2");
                        break;
                    case VOS_NT:
                        puts("NT");
                        break;
                    default:
                        puts("(unknown)");
                        break;
                }
          }

          /* file type */
          fputs("Type:            ", stdout);
          switch (fixed_info->dwFileType)
            {
                case VFT_APP:
                    puts("Exe");
                    break;
                case VFT_DLL:
                    puts("DLL");
                    break;
                case VFT_DRV:
                    switch (fixed_info->dwFileSubtype)
                      {
                          case VFT2_DRV_COMM:
                              puts("driver (serial)");
                              break;
                          case VFT2_DRV_PRINTER:
                              puts("driver (printer)");
                              break;
                          case VFT2_DRV_KEYBOARD:
                              puts("driver (keyboard)");
                              break;
                          case VFT2_DRV_LANGUAGE:
                              puts("driver (language)");
                              break;
                          case VFT2_DRV_DISPLAY:
                              puts("driver (screen)");
                              break;
                          case VFT2_DRV_MOUSE:
                              puts("driver (mouse)");
                              break;
                          case VFT2_DRV_NETWORK:
                              puts("driver (network)");
                              break;
                          case VFT2_DRV_SYSTEM:
                              puts("driver (system)");
                              break;
                          case VFT2_DRV_INSTALLABLE:
                              puts("driver (installable)");
                              break;
                          case VFT2_DRV_SOUND:
                              puts("driver (sound)");
                              break;
                          case VFT2_UNKNOWN:
                          default:
                              puts("driver (unknown)");
                              break;
                      }

                    break;
                case VFT_FONT:
                    switch (fixed_info->dwFileSubtype)
                      {
                          case VFT2_FONT_RASTER:
                              puts("font (raster)");
                              break;
                          case VFT2_FONT_VECTOR:
                              puts("font (vector)");
                              break;
                          case VFT2_FONT_TRUETYPE:
                              puts("font (truetype)");
                              break;
                          case VFT2_UNKNOWN:
                          default:
                              puts("font (unknown)");
                              break;
                      }

                    break;

                case VFT_VXD:
                    printf("virtual device (VxD), device id == %ld\n", fixed_info->dwFileSubtype);
                    break;
                case VFT_STATIC_LIB:
                    puts("static Lib");
                    break;
                case VFT_UNKNOWN:
                default:
                    puts("(unknown)");
                    break;
            }


          /* languages and strings */
          {
              LPDWORD langs;
              UINT len, i;
              char buffer[MAX_PATH];

              VerQueryValue(info, "\\VarFileInfo\\Translation", &langs, &len);

              for (i = 0; i < len; i += sizeof(*langs), langs++)
                {               /* Get the string name for the language number. */
                    VerLanguageName(LOWORD(*langs), buffer, sizeof(buffer));
                    fputs("- ", stdout);
                    puts(buffer);
                    ShowStrings(info, *langs);
                }
          }

          free(info);

      }
}
Esempio n. 24
0
/*
** Called when tab is displayed.
**
*/
void CDialogAbout::CTabPlugins::Initialize()
{
	m_Initialized = true;

	// Add columns to the list view
	HWND item = GetDlgItem(m_Window, IDC_ABOUTPLUGINS_ITEMS_LISTVIEW);

	LVCOLUMN lvc;
	lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
	lvc.fmt = LVCFMT_LEFT;  // left-aligned column
	lvc.iSubItem = 0;
	lvc.cx = 140;
	lvc.pszText = GetString(ID_STR_NAME);
	ListView_InsertColumn(item, 0, &lvc);
	lvc.iSubItem = 1;
	lvc.cx = 80;
	lvc.pszText = GetString(ID_STR_VERSION);
	ListView_InsertColumn(item, 1, &lvc);
	lvc.iSubItem = 2;
	lvc.cx = 310;
	lvc.pszText = GetString(ID_STR_AUTHOR);
	ListView_InsertColumn(item, 2, &lvc);

	LVITEM vitem;
	vitem.mask = LVIF_TEXT;
	vitem.iItem = 0;
	vitem.iSubItem = 0;

	// Scan for plugins
	WIN32_FIND_DATA fileData;      // Data structure describes the file found
	HANDLE hSearch;                // Search handle returned by FindFirstFile

	std::wstring files = Rainmeter->GetPluginPath() + L"*.dll";

	// Start searching for .ini files in the given directory.
	hSearch = FindFirstFile(files.c_str(), &fileData);
	int index = 0;
	do
	{
		if (hSearch == INVALID_HANDLE_VALUE) break;    // No more files found

		// Try to get the version and author
		std::wstring tmpSz = Rainmeter->GetPluginPath() + fileData.cFileName;
		const WCHAR* path = tmpSz.c_str();

		vitem.iItem = index;
		vitem.pszText = fileData.cFileName;

		// Try to get version and author from file resources first
		DWORD handle;
		DWORD versionSize = GetFileVersionInfoSize(path, &handle);
		if (versionSize)
		{
			bool found = false;
			void* data = new BYTE[versionSize];
			if (GetFileVersionInfo(path, 0, versionSize, data))
			{
				UINT len;
				struct LANGCODEPAGE
				{
					WORD wLanguage;
					WORD wCodePage;
				} *lcp;

				if (VerQueryValue(data, L"\\VarFileInfo\\Translation", (LPVOID*)&lcp, &len))
				{
					WCHAR key[64];
					LPWSTR value;

					_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\ProductName", lcp[0].wLanguage, lcp[0].wCodePage);
					if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len) &&
						wcscmp(value, L"Rainmeter") == 0)
					{
						ListView_InsertItem(item, &vitem);
						++index;
						found = true;

						_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\FileVersion", lcp[0].wLanguage, lcp[0].wCodePage);
						if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
						{
							ListView_SetItemText(item, vitem.iItem, 1, value);
						}

						_snwprintf_s(key, _TRUNCATE, L"\\StringFileInfo\\%04x%04x\\LegalCopyright", lcp[0].wLanguage, lcp[0].wCodePage);
						if (VerQueryValue(data, (LPTSTR)(LPCTSTR)key, (void**)&value, &len))
						{
							ListView_SetItemText(item, vitem.iItem, 2, value);
						}
					}
				}
			}

			delete [] data;
			if (found) continue;
		}

		// Try old calling GetPluginVersion/GetPluginAuthor for backwards compatibility
		DWORD err = 0;
		HMODULE dll = CSystem::RmLoadLibrary(path, &err, true);
		if (dll)
		{
			ListView_InsertItem(item, &vitem);
			++index;

			GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
			if (GetVersionFunc)
			{
				UINT version = GetVersionFunc();
				WCHAR buffer[64];
				_snwprintf_s(buffer, _TRUNCATE, L"%u.%u", version / 1000, version % 1000);
				ListView_SetItemText(item, vitem.iItem, 1, buffer);
			}

			GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");
			if (GetAuthorFunc)
			{
				LPCTSTR author = GetAuthorFunc();
				if (author && *author)
				{
					ListView_SetItemText(item, vitem.iItem, 2, (LPWSTR)author);
				}
			}

			FreeLibrary(dll);
		}
		else
		{
			LogWithArgs(LOG_ERROR, L"Unable to load plugin: %s (%u)", tmpSz.c_str(), err);
		}
	}
	while (FindNextFile(hSearch, &fileData));

	FindClose(hSearch);
}
Esempio n. 25
0
//==============================================================================================
// FUNCTION: GetFileVersion
// PURPOSE:  
//
BOOL CMCTeleClientDlg::GetFileVersion( char * pszFileVer, UINT uSize )
{
   // write application's executable file name
   // in the local string buffer for use with
   // GetFileVersionInfoSize( ) and GetFileVersionInfo( )
   sprintf( pszFileVer, "%s.exe", AfxGetAppName( ) );

   // find out how big the version info resource is
   DWORD dwVersionInfoSize = 0;
   DWORD dwHandle          = 0;
   dwVersionInfoSize = GetFileVersionInfoSize( pszFileVer, &dwHandle );
   if( dwVersionInfoSize == 0 )
   {
      ASSERT( FALSE );
      return FALSE;
   }

   // allocate version info buffer
   char* pVersionInfoBuf = new char[dwVersionInfoSize];
   if ( pVersionInfoBuf == NULL )
   {
      ASSERT( FALSE );
      return FALSE;
   }

   // read the version info data
   if( !GetFileVersionInfo( pszFileVer,
                            dwHandle,
                            dwVersionInfoSize,
                            pVersionInfoBuf    ) )
   {
      ASSERT( FALSE );
      delete pVersionInfoBuf;
      return FALSE;
   }               

   // some variables we will need for VerQueryValue( )
   void* pvVersionString    = NULL;
   UINT  uVersionStringSize = 0;

   /////////////////////////////////////////////////////////////////
   // initialize file verison string
   /////////////////////////////////////////////////////////////////
   if( !VerQueryValue( pVersionInfoBuf, 
                       "\\StringFileInfo\\040904B0\\FileVersion", 
                       &pvVersionString,
                       &uVersionStringSize 
                      ) )
   {
      ASSERT( FALSE );
      delete pVersionInfoBuf;
      return FALSE;
   }
   else
   {   
      // truncate version string if it exceeds our buffer length
      if( uVersionStringSize >= uSize )
      {
         // -1 to guarantee at least 1 '\0'
         uVersionStringSize = uSize - 1;
      }
      memset( pszFileVer, '\0', uSize );
      strncpy(pszFileVer, (char*) pvVersionString, uVersionStringSize);
   }

   delete [] pVersionInfoBuf;
   return TRUE;
}
Esempio n. 26
0
BOOL GetProgramVersion(LPTSTR szFileName,
                       int nVersionMin[3],
                       int nVersionMax[3],
                       DWORD dwLangId
                       )
{
        DWORD dwZero, dwVerInfoSize;
        LPVOID lpData;
        LPVOID lpBuffer;
        UINT uBytes;
        VS_FIXEDFILEINFO *pVsFixedFileInfo;
        INT nVersionNums[3], i;
        WORD* pdwLangIds;
        BOOL boolIsLangSupported = FALSE;

        if(szFileName == NULL)
                return FALSE;

        dwVerInfoSize = GetFileVersionInfoSize(szFileName, &dwZero);
        if(!dwVerInfoSize)
                return FALSE;
        
        lpData = HeapAlloc(GetProcessHeap(), 0, dwVerInfoSize);
        if(!lpData)
                return FALSE;
        __try {
                if(!GetFileVersionInfo(szFileName, 0, dwVerInfoSize, lpData))
                        return FALSE;

                if(!VerQueryValue(lpData, "\\", &lpBuffer, &uBytes))
                        return FALSE;

                if( uBytes == 0 )
                        return FALSE;
                
                pVsFixedFileInfo = (VS_FIXEDFILEINFO *)lpBuffer;
                nVersionNums[0] = HIWORD(pVsFixedFileInfo-> dwFileVersionMS);
                nVersionNums[1] = LOWORD(pVsFixedFileInfo->dwFileVersionMS);
                nVersionNums[2] = pVsFixedFileInfo->dwFileVersionLS;

                if(dwLangId == 0)
                        __leave;

                if(!VerQueryValue(lpData, "\\VarFileInfo\\Translation", &lpBuffer, &uBytes))
                        return FALSE;

                if(uBytes == 0)
                        return FALSE;
                
                pdwLangIds = (WORD *)lpBuffer;

                for(i = 0; i < (INT)(uBytes/sizeof(WORD)); i++)
                {
                        if(pdwLangIds[i] == dwLangId)
                        {
                                boolIsLangSupported = TRUE;
                                break;
                        }
                }

                if( !boolIsLangSupported )
                        return FALSE;

        } __finally {
                if(lpData)
                        HeapFree(GetProcessHeap(), 0, lpData);
        }

        return TRUE;
}
Esempio n. 27
0
CKDApp::CKDApp()
	:	m_bRestart(false),
#ifdef KDAPP_ENABLE_GETAPPOTHERDIR
		m_lpAppConfDir(NULL), m_lpAppLangDir(NULL),
#endif //KDAPP_ENABLE_GETAPPOTHERDIR
#ifdef KDAPP_ENABLE_GETAPPVERSION
		m_lpAppFileVer(NULL), m_lpAppProductVer(NULL),
#endif //KDAPP_ENABLE_GETAPPVERSION
#ifdef KDAPP_ENABLE_UPDATEAPPONLINE
		m_bUpdateApp(false), m_bShowUpdateMsg(true), m_lpTmpBatchPath(NULL),
#endif //KDAPP_ENABLE_UPDATEAPPONLINE
		m_lpAppName(NULL), m_lpAppPath(NULL), m_lpAppDir(NULL)
{
	size_t u64Len;
	TCHAR sBuffer[MAX_PATH], *ptr;

	u64Len = GetModuleFileName(NULL, sBuffer, MAX_PATH);
	if (u64Len) {
		m_lpAppPath = new TCHAR[u64Len + 1];
		_tcscpy((LPTSTR)m_lpAppPath, sBuffer);
	}

	ptr = _tcsrchr(sBuffer, _T('\\'));
	if (ptr) {
		ptr++;
		PathRemoveExtension(ptr);
		m_lpAppName = new TCHAR[_tcslen(ptr) + 1];
		_tcscpy((LPTSTR)m_lpAppName, ptr);
		*(ptr) = _T('\0');
		SetCurrentDirectory(sBuffer);

		u64Len = _tcslen(sBuffer) + 1;
		m_lpAppDir = new TCHAR[u64Len];
		_tcscpy((LPTSTR)m_lpAppDir, sBuffer);

#ifdef KDAPP_ENABLE_GETAPPOTHERDIR
		m_lpAppConfDir = new TCHAR[u64Len + _tcslen(_T("conf\\"))];
		_stprintf((LPTSTR)m_lpAppConfDir, _T("%sconf\\"), m_lpAppDir);
		if (!PathFileExists(m_lpAppConfDir))
			::CreateDirectory(m_lpAppConfDir, NULL);

		m_lpAppLangDir = new TCHAR[u64Len + _tcslen(_T("lang\\"))];
		_stprintf((LPTSTR)m_lpAppLangDir, _T("%slang\\"), m_lpAppDir);
		if (!PathFileExists(m_lpAppLangDir))
			::CreateDirectory(m_lpAppLangDir, NULL);
#endif //KDAPP_ENABLE_GETAPPOTHERDIR

#ifdef KDAPP_ENABLE_UPDATEAPPONLINE
		m_lpTmpBatchPath = new TCHAR[u64Len + _tcslen(_T("tmp.cmd"))];
		_stprintf((LPTSTR)m_lpTmpBatchPath, _T("%stmp.vbs"), m_lpAppDir);
#endif
	} else {
		MessageBox(NULL, _T("Can not locate the execution file!"), _T("ERROR"), MB_OK | MB_ICONERROR);
	}

#ifdef KDAPP_ENABLE_GETAPPVERSION
	if (m_lpAppPath) {
		u64Len = GetFileVersionInfoSize(m_lpAppPath, NULL);
		while (u64Len) {
			struct LANGANDCODEPAGE {
				WORD wLanguage;
				WORD wCodePage;
			} *lpTranslate;

			CString sQuery;
			CString sVer;
			TCHAR *btVersion;
			UINT uVersionLen;
			BYTE *pData = new BYTE[u64Len];

			GetFileVersionInfo(m_lpAppPath, NULL, u64Len, pData);

			if (!VerQueryValue(pData, _T("\\VarFileInfo\\Translation"), (LPVOID*)&lpTranslate, &uVersionLen))
				break;

			sQuery.Format(_T("\\StringFileInfo\\%04x%04x\\FileVersion"), lpTranslate[0].wLanguage, lpTranslate[0].wCodePage);
			if (VerQueryValue(pData, (LPTSTR)(LPCTSTR)sQuery, (LPVOID *)&btVersion, &uVersionLen)) {
				sVer = btVersion;
				sVer.Replace(_T(" "), _T(""));
				sVer.Replace(_T(","), _T("."));
				m_lpAppFileVer = new TCHAR[uVersionLen + 1];
				_tcscpy((LPTSTR)m_lpAppFileVer, sVer);
			}

			sQuery.Format(_T("\\StringFileInfo\\%04x%04x\\ProductVersion"), lpTranslate[0].wLanguage, lpTranslate[0].wCodePage);
			if (VerQueryValue(pData, (LPTSTR)(LPCTSTR)sQuery, (LPVOID *)&btVersion, &uVersionLen)) {
				sVer = btVersion;
				sVer.Replace(_T(" "), _T(""));
				sVer.Replace(_T(","), _T("."));
				m_lpAppProductVer = new TCHAR[uVersionLen + 1];
				_tcscpy((LPTSTR)m_lpAppProductVer, sVer);
			}

			delete [] pData;
			break;
		}
	}
#endif //KDAPP_ENABLE_GETAPPVERSION
}
Esempio n. 28
0
DWORD
GetDriverMajorVersion(
    LPWSTR pFileName
    )
{
     DWORD dwSize = 0;
     LPVOID pFileVersion;
     UINT  uLen = 0;
     LPVOID pMem;
     DWORD dwFileOS;
     DWORD dwFileVersionMS;
     DWORD dwFileVersionLS;
     DWORD dwProductVersionMS;
     DWORD dwProductVersionLS;


     if (!(dwSize = GetFileVersionInfoSize(pFileName, 0))) {
         DBGMSG(DBG_TRACE, ("Error: GetFileVersionInfoSize failed with %d\n", GetLastError()));
         DBGMSG(DBG_TRACE, ("Returning back a version # 0\n"));
         return(0);
     }
     if (!(pMem = AllocSplMem(dwSize))) {
         DBGMSG(DBG_TRACE, ("AllocMem  failed \n"));
         DBGMSG(DBG_TRACE, ("Returning back a version # 0\n"));
         return(0);
     }
     if (!GetFileVersionInfo(pFileName, 0, dwSize, pMem)) {
         FreeSplMem(pMem);
         DBGMSG(DBG_TRACE, ("GetFileVersionInfo failed\n"));
         DBGMSG(DBG_TRACE, ("Returning back a version # 0\n"));
         return(0);
     }
     if (!VerQueryValue(pMem, L"\\",
                            &pFileVersion, &uLen)) {
        FreeSplMem(pMem);
        DBGMSG(DBG_TRACE, ("VerQueryValue failed \n"));
        DBGMSG(DBG_TRACE, ("Returning back a version # 0\n"));
        return(0);
     }

     //
     // We could determine the Version Information
     //

     DBGMSG(DBG_TRACE, ("dwFileVersionMS =  %d\n", ((VS_FIXEDFILEINFO *)pFileVersion)->dwFileVersionMS));
     DBGMSG(DBG_TRACE, ("dwFileVersionLS = %d\n", ((VS_FIXEDFILEINFO *)pFileVersion)->dwFileVersionLS));

     DBGMSG(DBG_TRACE, ("dwProductVersionMS = %d\n", ((VS_FIXEDFILEINFO *)pFileVersion)->dwProductVersionMS));
     DBGMSG(DBG_TRACE, ("dwProductVersionLS =  %d\n", ((VS_FIXEDFILEINFO *)pFileVersion)->dwProductVersionLS));

     dwFileOS = ((VS_FIXEDFILEINFO *)pFileVersion)->dwFileOS;
     dwFileVersionMS = ((VS_FIXEDFILEINFO *)pFileVersion)->dwFileVersionMS;
     dwFileVersionLS = ((VS_FIXEDFILEINFO *)pFileVersion)->dwFileVersionLS;

     dwProductVersionMS = ((VS_FIXEDFILEINFO *)pFileVersion)->dwProductVersionMS;
     dwProductVersionLS = ((VS_FIXEDFILEINFO *)pFileVersion)->dwProductVersionLS;

     FreeSplMem(pMem);

     if (dwFileOS != VOS_NT_WINDOWS32) {
         DBGMSG(DBG_TRACE,("Returning back a version # 0\n"));
         return(0);
     }

     if (dwProductVersionMS == dwFileVersionMS) {

         //
         // This means this hold for all dlls Pre-Daytona
         // after Daytona, printer driver writers must support
         // version control or we'll dump them as Version 0
         // drivers


         DBGMSG(DBG_TRACE,("Returning back a version # 0\n"));
         return(0);
     }

     //
     // Bug-Bug: suppose a third-party vendor uses a different system
     // methinks we should use the lower dword to have  specific value
     // which implies he/she supports spooler version -- check with MattFe

     DBGMSG(DBG_TRACE,("Returning back a version # %d\n", dwFileVersionMS));

     return(dwFileVersionMS);
}
Esempio n. 29
0
int CSVPNet::SetCURLopt(CURL *curl)
{
	//struct curl_slist *headerlist=NULL;
	//static const char buf[] = "Expect:";
	AppSettings& s = AfxGetAppSettings();

	char buff[MAX_PATH];
	if(s.szOEMTitle.IsEmpty()){
		sprintf_s( buff, "SPlayer Build %d", SVP_REV_NUMBER );
	}else{
		CSVPToolBox svpToolBox;
		int iDescLen = 0;
		char *oem = svpToolBox.CStringToUTF8(s.szOEMTitle, &iDescLen);
		sprintf_s( buff, "SPlayer Build %d OEM%s", SVP_REV_NUMBER ,oem );
		free(oem);
	}
	char buff_cookie[UNIQU_HASH_SIZE];
	memset(buff_cookie,0,UNIQU_HASH_SIZE);
	{
		
		CString path;
		GetModuleFileName(NULL, path.GetBuffer(MAX_PATH), MAX_PATH);
		path.ReleaseBuffer();
		int Ret = -1;
		path.MakeLower();
		//SVP_LogMsg5(L"got splayer path %s" ,path);
		if( path.Find(_T("splayer")) >= 0 || path.Find(_T("svplayer")) >= 0 || path.Find(_T("mplayerc")) >= 0  ){
			DWORD             dwHandle;
			UINT              dwLen;
			UINT              uLen;
			UINT              cbTranslate;
			LPVOID            lpBuffer;

			dwLen  = GetFileVersionInfoSize(path, &dwHandle);

			TCHAR * lpData = (TCHAR*) malloc(dwLen);
			if(lpData){
				
			memset((char*)lpData, 0 , dwLen);


				/* GetFileVersionInfo() requires a char *, but the api doesn't
				* indicate that it will modify it */
				if(GetFileVersionInfo(path, dwHandle, dwLen, lpData) != 0)
				{
					
						CString szParm( _T("\\StringFileInfo\\000004b0\\FileDescription"));

						if(VerQueryValue(lpData, szParm, &lpBuffer, &uLen) != 0)
						{

							CString szProductName((TCHAR*)lpBuffer);
							//SVP_LogMsg3("szProductName %s", szProductName);
							szProductName.MakeLower();

							if(szProductName.Find(_T("射手")) >= 0 || szProductName.Find(_T("splayer")) >= 0  ){
								Ret = 125;
								
							}
						}

				
				}
			}
		}
		if(Ret == 125){
			//sprintf_s(buff_cookie , UNIQU_HASH_SIZE, "UQID=%s", uniqueIDHash);
			//curl_easy_setopt(curl, CURLOPT_COOKIE , buff_cookie);
		}else{
			//sprintf_s(buff_cookie , UNIQU_HASH_SIZE, "UQID=%s", uniqueIDHash);
			
			//curl_easy_setopt(curl, CURLOPT_COOKIE , buff_cookie);
		}
	}
	

	curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1);
	curl_easy_setopt(curl, CURLOPT_USERAGENT, buff);

	curl_easy_setopt(curl, CURLOPT_TIMEOUT, 40);
	curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 20);
	curl_easy_setopt(curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_0); //must use 1.0 for proxy

	curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
	//curl_easy_setopt(curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv2);
#if 1
    if(iTryID%2 == 0){
	    DWORD ProxyEnable = 0;
	    CString ProxyServer;
	    DWORD ProxyPort = 0;

	    ULONG len = 256+1;
	    CRegKey key;
	    if( ERROR_SUCCESS == key.Open(HKEY_CURRENT_USER, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), KEY_READ)
		    && ERROR_SUCCESS == key.QueryDWORDValue(_T("ProxyEnable"), ProxyEnable) && ProxyEnable
		    && ERROR_SUCCESS == key.QueryStringValue(_T("ProxyServer"), ProxyServer.GetBufferSetLength(256), &len))
	    {
    		

    	
		    CStringA p_str("http://");
		    p_str.Append(CStringA(ProxyServer));
		    curl_easy_setopt(curl, CURLOPT_PROXY,  p_str.GetBuffer());//
		    p_str.ReleaseBuffer();
		    //curl_easy_setopt(curl, CURLOPT_PROXYPORT, 3128);
		    //p_str.ReleaseBuffer();
		    //curl_easy_setopt(curl,CURLOPT_PROXYTYPE,CURLPROXY_HTTP_1_0);
		    SVP_LogMsg6("Using proxy %s", p_str);
    	
		    //ProxyServer.ReleaseBufferSetLength(len);
	    }else{
		    //curl_easy_setopt(curl,CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_NONE);
	    }
    }
#endif

    if(fp_curl_verbose){
	    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
        curl_easy_setopt(curl, CURLOPT_STDERR, fp_curl_verbose);
    }

    //SVP_LogMsg5(L"iTryID %d", iTryID);
	//curl_easy_setopt(curl, CURLOPT_ENCODING, "gzip"); not native supported. so dont use this option
	// MUST not have this line curl_easy_setopt(curl, CURLOPT_POST, ....);
	
	//headerlist = curl_slist_append(headerlist, buf); //WTF ??
	//curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headerlist);
	return 0;
}
LRESULT CALLBACK GeneralPage(HWND hDlg, UINT unMsg, WPARAM /*wParam*/, LPARAM lParam)
{
/******************************************************************************
 *
 *  G e n e r a l P a g e
 *
 ******************************************************************************
 *
 *  Input:  hDlg - Handle to the page dialog
 *          unMsg - Message ID
 *          wParam - WPARAM message parameter
 *          lParam - LPARAM message parameter
 *
 *  Return: FALSE if message is not processed
 *          TRUE if message is processed here
 *
 *  Description: This is the window procedure for the "General" page dialog
 *               of the property sheet dialog box. All the Property Sheet
 *               related events are passed as WM_NOTIFY messages and they
 *               are identified within the LPARAM which will be pointer to
 *               the NMDR structure
 *****************************************************************************/
	HINSTANCE hInstance = (HINSTANCE) GetWindowLongPtr(hDlg, GWLP_HINSTANCE);

	switch (unMsg)
	{
	case WM_INITDIALOG:
		{
			char szText[256];
			char szWindowText[MAXPATHLEN];
			char szFullPath[MAXPATHLEN];
			int index = 0;
			const int NCOLS = 3;

			// Display the number of times the server has been started by
			//   this session of the guardian
			SetDlgItemInt(hDlg, IDC_RESTARTS, nRestarts, FALSE);

			// get the path to the exe.
			// Make sure that it is null terminated
			GetModuleFileName(hInstance, szWindowText, sizeof(szWindowText));
			char* pszPtr = strrchr(szWindowText, '\\');
			*(pszPtr + 1) = 0x00;

			ChopFileName(szWindowText, szWindowText, 38);
			SetDlgItemText(hDlg, IDC_LOCATION, szWindowText);

			// Get version information from the application
			GetModuleFileName(hInstance, szFullPath, sizeof(szFullPath));
			DWORD dwVerHnd;
			const DWORD dwVerInfoSize = GetFileVersionInfoSize(szFullPath, &dwVerHnd);
			if (dwVerInfoSize)
			{
				// If we were able to get the information, process it:
				UINT cchVer = 25;
				LPSTR lszVer = NULL;

				HANDLE hMem = GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
				LPVOID lpvMem = GlobalLock(hMem);
				GetFileVersionInfo(szFullPath, dwVerHnd, dwVerInfoSize, lpvMem);
				if (VerQueryValue(lpvMem, "\\StringFileInfo\\040904E4\\FileVersion",
					 reinterpret_cast<void**>(&lszVer), &cchVer))
				{
					SetDlgItemText(hDlg, IDC_VERSION, lszVer);
				}
				else
					SetDlgItemText(hDlg, IDC_VERSION, "N/A");
				GlobalUnlock(hMem);
				GlobalFree(hMem);
			}

			// Create the columns Action, Date, Time for the listbox
			HWND hWndLog = GetDlgItem(hDlg, IDC_LOG);
			LV_COLUMN lvC;
			lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvC.fmt = LVCFMT_LEFT;	// left-align column
			lvC.pszText = szText;

			for (index = 0; index < NCOLS; index++)
			{
				// NOTE:  IDS_ACTION = 220
				// IDS_DATE   = 230
				// IDS_TIME   = 240
				lvC.iSubItem = index;
				lvC.cx = 85;
				LoadString(hInstance, IDS_ACTION + (index * 10), szText, sizeof(szText));
				ListView_InsertColumn(hWndLog, index, &lvC);
			}

			log_info* liTemp = log_entry->next;
			LV_ITEM lvI;
			lvI.cchTextMax = sizeof(liTemp->log_action);
			lvI.mask = LVIF_TEXT;
			for (index = 0; liTemp->log_action; index++, liTemp = liTemp->next)
			{
				lvI.iItem = index;
				lvI.iSubItem = 0;
				lvI.pszText = liTemp->log_action;
				ListView_InsertItem(hWndLog, &lvI);
				ListView_SetItemText(hWndLog, index, 0, lvI.pszText);

				lvI.iSubItem = 1;
				lvI.pszText = liTemp->log_date;
				ListView_InsertItem(hWndLog, &lvI);
				ListView_SetItemText(hWndLog, index, 1, lvI.pszText);

				lvI.iSubItem = 2;
				lvI.pszText = liTemp->log_time;
				ListView_InsertItem(hWndLog, &lvI);
				ListView_SetItemText(hWndLog, index, 2, lvI.pszText);
			}
		}
		break;
	case WM_NOTIFY:
		switch (((LPNMHDR) lParam)->code)
		{
		case PSN_KILLACTIVE:
			SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
			break;
		}
		break;
	}
	return FALSE;
}