Example #1
0
int CSetOverlayHandlers::GetInstalledOverlays()
{
    // if there are more than 12 overlay handlers installed, then that means not all
    // of the overlay handlers can be shown. Windows chooses the ones first
    // returned by RegEnumKeyEx() and just drops the ones that come last in
    // that enumeration.
    int nInstalledOverlayhandlers = 0;
    // scan the registry for installed overlay handlers
    HKEY hKey;
    if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,
        _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers"),
        0, KEY_ENUMERATE_SUB_KEYS, &hKey)==ERROR_SUCCESS)
    {
        TCHAR value[2048];
        TCHAR keystring[2048];
        for (int i = 0, rc = ERROR_SUCCESS; rc == ERROR_SUCCESS; i++)
        {
            DWORD size = _countof(value);
            FILETIME last_write_time;
            rc = RegEnumKeyEx(hKey, i, value, &size, NULL, NULL, NULL, &last_write_time);
            if (rc == ERROR_SUCCESS)
            {
                if (_tcsnicmp(&value[1], L"tortoise", 8) != 0)
                {
                    // check if there's a 'default' entry with a guid
                    _tcscpy_s(keystring, _T("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\"));
                    _tcscat_s(keystring, value);
                    DWORD dwType = 0;
                    DWORD dwSize = _countof(value); // the API docs only specify "The size of the destination data buffer",
                    // but better be safe than sorry using _countof instead of sizeof
                    if (SHGetValue(HKEY_LOCAL_MACHINE,
                        keystring,
                        NULL,
                        &dwType, value, &dwSize) == ERROR_SUCCESS)
                    {
                        if ((dwSize > 10)&&(value[0] == '{'))
                            nInstalledOverlayhandlers++;
                    }
                }
            }
        }
        RegCloseKey(hKey);
    }
    return nInstalledOverlayhandlers;
}
Example #2
0
bool SetupDirectInputProxy()
{
	TCHAR szPath[MAX_PATH];
	GetSystemDirectory(szPath, MAX_PATH);
	_tcscat_s(szPath, TEXT("\\dinput8.dll"));
	hOrigDLL = LoadLibrary(szPath);

	if (hOrigDLL != NULL)
	{
		OldDirectInput8Create = GetProcAddress(hOrigDLL, "DirectInput8Create");
		OldDllCanUnloadNow = GetProcAddress(hOrigDLL, "DllCanUnloadNow");
		OldDllGetClassObject = GetProcAddress(hOrigDLL, "DllGetClassObject");
		OldDllRegisterServer = GetProcAddress(hOrigDLL, "DllRegisterServer");
		OldDllUnregisterServer = GetProcAddress(hOrigDLL, "DllUnregisterServer");
	}

	return OldDirectInput8Create != NULL && OldDllCanUnloadNow != NULL && OldDllGetClassObject != NULL && OldDllRegisterServer != NULL && OldDllUnregisterServer != NULL;
}
Example #3
0
void CUT_Str::cvtcat(wchar_t * dest, size_t size, const char * source)
{
	*dest = _T('\0');
	size_t len = strlen(source);
	if(len > 0) 
	{
		++len;
		_TCHAR *szConverted = new _TCHAR[len+1];
		mbstowcs(szConverted, len, source, len);
#if _MSC_VER >= 1400
		_tcscat_s(dest, size, szConverted);
#else
		UNREFERENCED_PARAMETER(size);
		::_tcscat(dest, szConverted);
#endif		
		delete [] szConverted;
	}
}
Example #4
0
/**
 * Get flags of SHGDNF type for debug log.
 */
LPCTSTR DbgGetSHGDNF(SHGDNF Flags)
{
   TCHAR szText[100] = { 0 };
   _tcscpy(szText, _T(""));
   static struct { DWORD f; LPCTSTR psz; } aList[] = {
      { SHGDN_FORADDRESSBAR, _T(" FORADDRESSBAR") },
      { SHGDN_FOREDITING,    _T(" FOREDITING") },
      { SHGDN_FORPARSING,    _T(" FORPARSING") },
      { SHGDN_INFOLDER,      _T(" INFOLDER") },
   };
   for( int i = 0; i < lengthof(aList); i++ ) {
      if( IsBitSet(Flags, aList[i].f) ) _tcscat_s(szText, lengthof(szText), aList[i].psz);
   }
   if( szText[0] == '\0' ) _tcscpy(szText, _T(" NORMAL"));
   static TCHAR s_szText[100] = { 0 };
   _tcscpy(s_szText, szText);
   return s_szText + 1;
}
Example #5
0
bool InitSQLite()
{
	static bool isInit = false;

	if (!isInit)
	{
		TCHAR dllPath[MAX_PATH];

		HMODULE hPlugin = ::GetModuleHandle(TEXT("ComparePlugin.dll"));
		if (!hPlugin)
			return false;

		::GetModuleFileName(hPlugin, (LPWSTR)dllPath, _countof(dllPath));
		::PathRemoveExtension(dllPath);
		_tcscat_s(dllPath, _countof(dllPath), TEXT("\\sqlite3.dll"));

		HMODULE ligSQLite = ::LoadLibrary(dllPath);
		if (!ligSQLite)
			return false;

		sqlite3_open16 = (PSQLOPEN16)::GetProcAddress(ligSQLite, "sqlite3_open16");
		if (!sqlite3_open16)
			return false;
		sqlite3_prepare16_v2 = (PSQLPREPARE16V2)::GetProcAddress(ligSQLite, "sqlite3_prepare16_v2");
		if (!sqlite3_prepare16_v2)
			return false;
		sqlite3_step = (PSQLSTEP)::GetProcAddress(ligSQLite, "sqlite3_step");
		if (!sqlite3_step)
			return false;
		sqlite3_column_text16 = (PSQLCOLUMNTEXT16)::GetProcAddress(ligSQLite, "sqlite3_column_text16");
		if (!sqlite3_column_text16)
			return false;
		sqlite3_finalize = (PSQLFINALZE)::GetProcAddress(ligSQLite, "sqlite3_finalize");
		if (!sqlite3_finalize)
			return false;
		sqlite3_close = (PSQLCLOSE)::GetProcAddress(ligSQLite, "sqlite3_close");
		if (!sqlite3_close)
			return false;

		isInit = true;
	}

	return true;
}
Example #6
0
HINSTANCE CLangDll::Init(LPCTSTR appname, unsigned long langID)
{
	TCHAR langpath[MAX_PATH] = {0};
	TCHAR langdllpath[MAX_PATH] = {0};
	TCHAR sVer[MAX_PATH] = {0};
	_tcscpy_s(sVer, MAX_PATH, _T(STRPRODUCTVER));
	GetModuleFileName(NULL, langpath, MAX_PATH);
	TCHAR * pSlash = _tcsrchr(langpath, '\\');
	if (pSlash)
	{
		*pSlash = 0;
		pSlash = _tcsrchr(langpath, '\\');
		if (pSlash)
		{
			*pSlash = 0;
			_tcscat_s(langpath, MAX_PATH, _T("\\Languages\\"));
			assert(m_hInstance == NULL);
			do
			{
				_stprintf_s(langdllpath, MAX_PATH, _T("%s%s%lu.dll"), langpath, appname, langID);

				m_hInstance = LoadLibrary(langdllpath);

				if (!DoVersionStringsMatch(sVer, langdllpath))
				{
					FreeLibrary(m_hInstance);
					m_hInstance = NULL;
				}
				if (m_hInstance == NULL)
				{
					DWORD lid = SUBLANGID(langID);
					lid--;
					if (lid > 0)
					{
						langID = MAKELANGID(PRIMARYLANGID(langID), lid);
					}
					else
						langID = 0;
				}
			} while ((m_hInstance == NULL) && (langID != 0));
		}
	}
	return m_hInstance;
}
Example #7
0
BOOL
	InitMod(
	__in_opt LPINIT_MOD_ARGUMENTS lpInitModArguments
	)
{
	BOOL				bRet					= FALSE;

	CRUSH_HANDLER_INFO	CrushHandlerInfo;
	TCHAR				tchLogPath[MAX_PATH]	= {0};
	LPTSTR				lpPosition				= NULL;


	__try
	{
		ZeroMemory(&CrushHandlerInfo, sizeof(CrushHandlerInfo));

		CrushHandlerInfo.EhType = EH_TYPE_S;
		CrushHandlerInfo.bFirstHandler = TRUE;
		CrushHandlerInfo.MiniDumpType = MiniDumpWithFullMemory;

		CSimpleDump::GetInstance()->RegisterCrushHandler(&CrushHandlerInfo);

		if (GetModuleFileName(NULL, tchLogPath, _countof(tchLogPath)))
		{
			lpPosition = _tcsrchr(tchLogPath, _T('.'));
			if (lpPosition)
			{
				*(lpPosition + 1) = _T('\0');
				_tcscat_s(tchLogPath, _countof(tchLogPath), _T("log"));

				if (!CSimpleLog::GetInstance(tchLogPath))
					printfEx(MOD_MAIN, PRINTF_LEVEL_ERROR, "SimpleLog.Init failed");
			}
		}

		bRet = TRUE;
	}
	__finally
	{
		;
	}

	return bRet;
}
PassRefPtr<Icon> Icon::createIconForFiles(const Vector<String>&)
{
#if PLATFORM(WINCE)
    return 0;
#else
    TCHAR buffer[MAX_PATH];    
    UINT length = ::GetSystemDirectory(buffer, ARRAYSIZE(buffer));
    if (!length)
        return 0;
    
    if (_tcscat_s(buffer, TEXT("\\shell32.dll")))
        return 0;

    HICON hIcon;
    if (!::ExtractIconEx(buffer, shell32MultipleFileIconIndex, 0, &hIcon, 1))
        return 0;
    return adoptRef(new Icon(hIcon));
#endif
}
Example #9
0
/// <summary>
/// Print the debug string.
/// </summary>
/// <param name="cstr">The CSTR.</param>
void DebugPrint(CString cstr)
{
	//http://msdn.microsoft.com/zh-cn/library/z5hh6ee9.aspx

	if(debugMode == DEBUG_MODE_NONE)
	{
		return ;
	}

	static int flag = TRUE;
	static TCHAR file[MAX_PATH];
	static DWORD first = GetTickCount();
	CString output;

	output.Format(_T("%08d "), GetTickCount() - first);
	output += cstr;
	output.Append(_T("\n"));
	output.Replace(_T("\r"), _T(""));

	if(flag)
	{
		TCHAR* ptrEnd;
		::GetModuleFileName(NULL, file, MAX_PATH);
		if((ptrEnd = _tcsrchr(file, '.')) != NULL )
		{
			*ptrEnd = '\0';
			_tcscat_s(file, MAX_PATH, _T(".log"));
		}
		DeleteFile(file);
		flag = FALSE;
	}
	  
	FILE *fp;
	_tfopen_s(&fp, file, _T("ac"));
	_ftprintf(fp, _T("%s"), output);
	fflush(fp);
	fclose(fp);

	if(debugMode == DEBUG_MODE_MESSAGE)
	{
		AfxMessageBox(output);
	}
}
Example #10
0
bool Settings::getPluginName(TCHAR out[]) {

	//=====================
	TCHAR path[MAX_PATH];
	int count;
	//=====================

	GetCurrentDirectory(MAX_PATH,path);

	_tcscat_s(path,_countof(path),_T("\\WinLIRC.ini"));

	count = GetPrivateProfileString(_T("WinLIRC"),_T("Plugin"),NULL,pluginName,_countof(pluginName),path);

	if(count) {
		_tcscpy_s(out,128,pluginName);
		return true;
	}

	return false;
}
Example #11
0
void ManagerResource< TypeItem >::Release( TCHAR* pNameFile )
{
	// ファイルパスの作成
	TCHAR	pPath[ _MAX_PATH ] = {};		// ファイルパス
	_tcscpy_s( pPath, _MAX_PATH, pDirectory_ );
	_tcscat_s( pPath, _MAX_PATH, pNameFile );

	// 存在しているか検索
	int		index;		// 要素番号
	index = GetId( pPath );
	if( index == -1 )
	{
		return;
	}

	// リソースの開放
	ReleaseResource( index );
	pBufferItem_[ index ].pItem_ = nullptr;
	pBufferItem_[ index ].Reinitialize();
}
Example #12
0
void TString::append(TString str)
{
	if(length == 0)
	{
		length = str.getStrLen();
		string = new TCHAR[length + 1];
		_tcscpy_s(string, length + 1, str.getString());
		return;
	}

	TCHAR* oldBuff = string;

	length += str.getStrLen();
	string = new TCHAR[length + 1];
	_tcscpy_s(string, length + 1, oldBuff);
	_tcscat_s(string, length + 1, str.getString());

	delete [] oldBuff;
	return;
}
Example #13
0
bool FindFileExt(LPCTSTR pstrPath, LPCTSTR pstrExtFilter)
{
    if (! pstrPath || ! pstrExtFilter)
    {
        return false;
    }

    TCHAR szExt[_MAX_EXT] = _T("");

    _tsplitpath_s(pstrPath, NULL, 0, NULL, 0, NULL, 0, szExt, _MAX_EXT);
    _tcslwr_s(szExt, _MAX_EXT);

    if(_tcslen(szExt))  
    {
        _tcscat_s(szExt, _MAX_EXT, _T(";"));    // .mo不符合条件,由于会匹配到.mov,所以在后面加上【;】来判断是否完全匹配
        return NULL != _tcsstr(pstrExtFilter, szExt);
    }

    return false;
}
Example #14
0
// DLL被加载、卸载时调用
BOOL APIENTRY DllMain(HMODULE hModule,
	DWORD  ul_reason_for_call,
	LPVOID lpReserved
	)
{
	TCHAR processPath[MAX_PATH];
	TCHAR msg[MAX_PATH + 20];

	switch (ul_reason_for_call)
	{
	case DLL_PROCESS_ATTACH:
		GetModuleFileName(GetModuleHandle(NULL), processPath, MAX_PATH);
		_tcscpy_s(msg, _T("注入了进程 "));
		_tcscat_s(msg, processPath);
		MessageBox(NULL, msg, _T(""), MB_OK);

		// 加载原DLL,获取真正的Direct3DCreate9地址
		g_d3d9Module = LoadLibrary(_T("C:\\Windows\\System32\\d3d9.dll"));
		RealDirect3DCreate9 = (Direct3DCreate9Type)GetProcAddress(g_d3d9Module, "Direct3DCreate9");
		if (RealDirect3DCreate9 == NULL)
		{
			MessageBox(NULL, _T("获取Direct3DCreate9地址失败"), _T(""), MB_OK);
			return FALSE;
		}

		break;

	case DLL_PROCESS_DETACH:
		MessageBox(NULL, _T("DLL卸载中"), _T(""), MB_OK);

		// 手动卸载原DLL
		FreeLibrary(g_d3d9Module);

		break;

	case DLL_THREAD_ATTACH:
	case DLL_THREAD_DETACH:
		break;
	}
	return TRUE;
}
Example #15
0
HRESULT CSubtitleSourceSSA::GetMediaType(CMediaType* pmt)
{
	CAutoLock cAutoLock(pStateLock());

	pmt->InitMediaType();
	pmt->SetType(&MEDIATYPE_Subtitle);
	pmt->SetSubtype(&MEDIASUBTYPE_SSA);
	pmt->SetFormatType(&FORMAT_SubtitleInfo);

	CSimpleTextSubtitle sts;
	sts.Open(CString(m_fn), DEFAULT_CHARSET);
	sts.RemoveAll();

	CFile f;
	TCHAR path[_MAX_PATH], fn[_MAX_PATH];
	if (!GetTempPath(MAX_PATH, path) || !GetTempFileName(path, _T("mpc_sts"), 0, fn)) {
		return E_FAIL;
	}

	_tremove(fn);

	_tcscat_s(fn, _T(".ssa"));

	if (!sts.SaveAs(fn, EXTSSA, -1, CTextFile::UTF8) || !f.Open(fn, CFile::modeRead)) {
		return E_FAIL;
	}

	int len = (int)f.GetLength()-3;
	f.Seek(3, CFile::begin);

	SUBTITLEINFO* psi = (SUBTITLEINFO*)pmt->AllocFormatBuffer(sizeof(SUBTITLEINFO) + len);
	memset(psi, 0, pmt->FormatLength());
	psi->dwOffset = sizeof(SUBTITLEINFO);
	strcpy_s(psi->IsoLang, "eng");
	f.Read(pmt->pbFormat + psi->dwOffset, len);
	f.Close();

	_tremove(fn);

	return NOERROR;
}
Example #16
0
/**
 * Get flags of PropertyStore GPS type for debug log.
 */
LPCTSTR DbgGetGPSF(GETPROPERTYSTOREFLAGS Flags)
{
   TCHAR szText[100] = { 0 };
   _tcscpy(szText, _T(""));
   static struct { DWORD f; LPCTSTR psz; } aList[] = {
      { GPS_HANDLERPROPERTIESONLY,   _T(" HANDLERPROPERTIESONLY") },
      { GPS_READWRITE,               _T(" READWRITE") },
      { GPS_TEMPORARY,               _T(" TEMPORARY") },
      { GPS_FASTPROPERTIESONLY,      _T(" FASTPROPERTIESONLY") },
      { GPS_OPENSLOWITEM,            _T(" OPENSLOWITEM") },
      { GPS_DELAYCREATION,           _T(" DELAYCREATION") },
      { GPS_BESTEFFORT,              _T(" BESTEFFORT") },
   };
   for( int i = 0; i < lengthof(aList); i++ ) {
      if( IsBitSet(Flags, aList[i].f) ) _tcscat_s(szText, lengthof(szText), aList[i].psz);
   }
   if( szText[0] == '\0' ) _tcscpy(szText, _T(" DEFAULT"));
   static TCHAR s_szText[100] = { 0 };
   _tcscpy(s_szText, szText);
   return s_szText + 1;
}
extern "C" __declspec(dllexport) bool SKSEPlugin_Load(const SKSEInterface * skse)
{
	// Get dll path.
	TCHAR DllFilePath[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, DllFilePath);
	_tcscat_s(DllFilePath, MAX_PATH, L"\\Data\\Plugins\\Sumwunn\\AchievementsModsEnabler.dll");

	// Return if already loaded.
	if (GetModuleHandle(DllFilePath) != 0) return 0;

	// Load it.
	HMODULE hModule = LoadLibrary(DllFilePath);
	FARPROC Function01 = GetProcAddress(hModule, "SetSKSEMode");
	FARPROC Function02 = GetProcAddress(hModule, "Setup");

	// Call stuff.
	Function01();
	Function02();

	return TRUE;
}
Example #18
0
LPCTSTR vibramouseSetupIniFilePath(void)
{
	// Create buffer for retrieve full path of INI file.
	const int bufferLength = MAX_PATH + 1;
	LPTSTR path = new TCHAR[bufferLength];
	::ZeroMemory(path, bufferLength);

	// Retrieve User Application Data Folder path (Typically C:\Users\<username>\AppData)
	HRESULT hResult = S_OK;
	hResult = SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, path);
	if (hResult != S_OK) {
		// If failed, Return default value(Maybe directing Windows folder...)
		return INIFILE_DEFAULT;
	}

	// Check Buffer space
	if (_tcslen(path) + _tcslen(INIFILE_DEFAULT) < bufferLength) {
		// Make full path of INI file.
		_tcscat_s(path, bufferLength, INIFILE_RELPATH);
		// MessageBox(hWnd, path, TEXT("[DEBUG]INIFILE"), MB_OK);

		// Create Directory of path
		LPTSTR dirPath = new TCHAR[bufferLength];
		memcpy(dirPath, path, bufferLength);
		TCHAR* lastBackslash = _tcsrchr(dirPath, _T('\\'));
		if (lastBackslash != NULL) {
			*lastBackslash = _T('\0');
		}
		// MessageBox(hWnd, dirPath, TEXT("[DEBUG]INIFILE DIR"), MB_OK);
		::CreateDirectory(dirPath, NULL);
		delete[] dirPath;

		// Complete!
		return path;
	}
	else {
		// Prevent Buffer Overrun
		return INIFILE_DEFAULT;
	}
}
Example #19
0
/* DLL loading */
static gboolean
init_dll_load_paths()
{
    TCHAR path_w[MAX_PATH];

    if (program_path && system_path && npcap_path)
        return TRUE;

    /* XXX - Duplicate code in filesystem.c:init_progfile_dir */
    if (GetModuleFileName(NULL, path_w, MAX_PATH) == 0 || GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
        return FALSE;
    }

    if (!program_path) {
        gchar *app_path;
        app_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL);
        /* We could use PathRemoveFileSpec here but we'd have to link to Shlwapi.dll */
        program_path = g_path_get_dirname(app_path);
        g_free(app_path);
    }

    if (GetSystemDirectory(path_w, MAX_PATH) == 0) {
        return FALSE;
    }

    if (!system_path) {
        system_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL);
    }

    _tcscat_s(path_w, MAX_PATH, _T("\\Npcap"));

    if (!npcap_path) {
        npcap_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL);
    }

    if (program_path && system_path && npcap_path)
        return TRUE;

    return FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// ConcatStrings
// Caller is responsible for 'delete'ing the string.
/////////////////////////////////////////////////////////////////////////////
TCHAR*
	ConcatStrings(
	LPCTSTR	FirstString,
	LPCTSTR	SecondString)
{
	TCHAR*	ConcatString		= NULL;

	if ((NULL != FirstString) || (NULL != SecondString))
	{
		try
		{
			if (NULL == FirstString)
			{
				ConcatString = GetStringCopy(SecondString);
			}
			else if (NULL == SecondString)
			{
				ConcatString = GetStringCopy(FirstString);
			}
			else
			{
				UINT	ConcatStringLength = (UINT)_tcslen(FirstString) +
					(UINT)_tcslen(SecondString) +
					1;

				ConcatString = new TCHAR[ConcatStringLength];

				_tcscpy_s(ConcatString, ConcatStringLength, FirstString);
				_tcscat_s(ConcatString, ConcatStringLength, SecondString);
			}
		}
		catch(TCHAR* Exception)
		{
			// log
			OutputDebugString(Exception);
			throw;
		}
	}
	return ConcatString;
}
Example #21
0
/**
 * Get flags of SFGAOF type for debug log.
 */
LPCTSTR DbgGetSFGAOF(SFGAOF Flags)
{
   TCHAR szText[300] = { 0 };
   _tcscpy(szText, _T(""));
   static struct { DWORD f; LPCTSTR psz; } aList[] = {
      { SFGAO_FOLDER,          _T(" FOLDER") },
      { SFGAO_BROWSABLE,       _T(" BROWSABLE") },
      { SFGAO_CANCOPY,         _T(" CANCOPY") },
      { SFGAO_CANMOVE,         _T(" CANMOVE") },
      { SFGAO_CANDELETE,       _T(" CANDELETE") },
      { SFGAO_CANRENAME,       _T(" CANRENAME") },
      { SFGAO_CANLINK,         _T(" CANLINK") },
      { SFGAO_SHARE,           _T(" SHARE") },      
      { SFGAO_HIDDEN,          _T(" HIDDEN") },
      { SFGAO_GHOSTED,         _T(" GHOSTED") },
      { SFGAO_READONLY,        _T(" READONLY") },
      { SFGAO_REMOVABLE,       _T(" REMOVABLE") },
      { SFGAO_ENCRYPTED,       _T(" ENCRYPTED") },
      { SFGAO_COMPRESSED,      _T(" COMPRESSED") },
      { SFGAO_ISSLOW,          _T(" ISSLOW") },
      { SFGAO_HASSUBFOLDER,    _T(" HASSUBFOLDER") },
      { SFGAO_DROPTARGET,      _T(" DROPTARGET") },
      { SFGAO_STORAGEANCESTOR, _T(" STORAGEANCESTOR") },
      { SFGAO_FILESYSANCESTOR, _T(" FILESYSANCESTOR") },
      { SFGAO_FILESYSTEM,      _T(" FILESYSTEM") },
      { SFGAO_HASPROPSHEET,    _T(" HASPROPSHEET") },
      { SFGAO_STREAM,          _T(" STREAM") },
      { SFGAO_NONENUMERATED,   _T(" NONENUMERATED") },
      { SFGAO_NEWCONTENT,      _T(" NEWCONTENT") },      
      { SFGAO_VALIDATE,        _T(" VALIDATE") },
   };
   for( int i = 0; i < lengthof(aList); i++ ) {
      if( IsBitSet(Flags, aList[i].f) ) _tcscat_s(szText, lengthof(szText), aList[i].psz);
   }
   if( szText[0] == '\0' ) _tcscpy(szText, _T(" "));
   if( _tcslen(szText) > 140 ) _tcscpy(szText, _T(" ..."));
   static TCHAR s_szText[150] = { 0 };
   _tcscpy(s_szText, szText);
   return s_szText + 1;
}
VOID FormatSizeInKB(DWORD dwSize, DWORD nCharacters, 
   LPTSTR szSize, size_t cchSize) {
   
   TCHAR szFormattedSize[64];
   if (StrFormatKBSize(dwSize, szFormattedSize, 
      _countof(szFormattedSize)) == NULL) {
      StringCchPrintf(szFormattedSize, _countof(szFormattedSize), TEXT("%8u"), dwSize); 
   }

   // Format to the right nCharacter width if needed.
   if (_tcslen(szFormattedSize) < nCharacters) {
      DWORD current = 0;
      for(current = 0; 
         current < (nCharacters - _tcslen(szFormattedSize)); 
         current++) {
         szSize[current] = TEXT(' ');
      }
      szSize[current] = TEXT('\0');      

      _tcscat_s(szSize, cchSize - current, szFormattedSize);
   }
}
Example #23
0
// This function moves files in the installed directory used by 3.22 or older under 'etc'.
void FuncDefs::MoveOldFile(LPCTSTR drive, LPCTSTR dir, LPCTSTR fname, LPCTSTR ext)
{
	TCHAR old[MAX_PATH];
	_tmakepath_s(old, drive, dir, fname, ext);
	if (!PathFileExists(old))
		return;
	TCHAR etc[MAX_PATH];
	_tmakepath_s(etc, drive, dir, _T("etc"), NULL);
	if (!PathFileExists(etc) && !CreateDirectory(etc, NULL) ||
			!PathIsDirectory(etc)) // a normal file 'etc' exists
		return;
	TCHAR newpath[MAX_PATH];
	_tmakepath_s(newpath, NULL, etc, fname, ext);
	if (MoveFile(old, newpath))
		return;
	// move an old file under 'etc' as a backup file.
	TCHAR backup[_MAX_FNAME] = _T("~");
	_tcscat_s(backup, fname);
	_tmakepath_s(newpath, NULL, etc, backup, ext);
	MoveFile(old, newpath);
	return;
}
Example #24
0
void CSetSavedDataPage::OnBnClickedAuthhistclear()
{
	CRegStdString auth = CRegStdString(_T("Software\\TortoiseGit\\Auth\\"));
	auth.removeKey();
	TCHAR pathbuf[MAX_PATH] = {0};
	if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, pathbuf)==S_OK)
	{
		_tcscat_s(pathbuf, MAX_PATH, _T("\\Subversion\\auth"));
		pathbuf[_tcslen(pathbuf)+1] = 0;
		SHFILEOPSTRUCT fileop;
		fileop.hwnd = this->m_hWnd;
		fileop.wFunc = FO_DELETE;
		fileop.pFrom = pathbuf;
		fileop.pTo = NULL;
		fileop.fFlags = FOF_NO_CONNECTED_ELEMENTS | FOF_NOCONFIRMATION;// | FOF_NOERRORUI | FOF_SILENT;
		fileop.lpszProgressTitle = _T("deleting file");
		SHFileOperation(&fileop);
	}
	m_btnAuthHistClear.EnableWindow(FALSE);
	m_tooltips.DelTool(GetDlgItem(IDC_AUTHHISTCLEAR));
	m_tooltips.DelTool(GetDlgItem(IDC_AUTHHISTORY));
}
Example #25
0
bool CAtom::LoadDefaults()
{
	int len = _tcslen(m_Name);
	if(len == 0)
	{
		_tcsncpy_s(m_Name, _T("???"), 3);
		return false;
	}

	bool found = false;
	for(int i=0;i<_countof(m_AtomDefaults);i++)
	{
		int deflen = _tcslen(m_AtomDefaults[i].name);
		int namelen = _tcslen(m_Name);
		if(deflen == namelen
			&& !_tcsncicmp(m_AtomDefaults[i].name, m_Name, deflen > namelen ? namelen : deflen))
		{
			found = true;
			_tcscpy_s(m_FullName, 20, m_AtomDefaults[i].full_name);
			m_Size = m_AtomDefaults[i].size;
			m_ColorR = m_AtomDefaults[i].color[0];
			m_ColorG = m_AtomDefaults[i].color[1];
			m_ColorB = m_AtomDefaults[i].color[2];
		}	
	}
	if(!found)
	{
		if (len < 4)
			_tcscat_s(m_Name, _T("*")); 
		//_tcsncpy_s(m_Name, 4, _T("?"), 3);
		_tcsncpy_s(m_FullName, 20, _T("UNKNOWN"), 7);
		m_Size = 1.0f;
		m_ColorR = 0.0f;
		m_ColorG = 1.0f;
		m_ColorB = 0.0f;
	}
	return found;
}
Example #26
0
/**
 * Get flags of SHCONTF type for debug log.
 */
LPCTSTR DbgGetSHCONTF(SHCONTF Flags)
{
   TCHAR szText[100] = { 0 };
   _tcscpy(szText, _T(""));
   static struct { DWORD f; LPCTSTR psz; } aList[] = {
      { SHCONTF_FOLDERS,        _T(" FOLDERS") },
      { SHCONTF_NONFOLDERS,     _T(" NONFOLDERS") },
      { SHCONTF_INCLUDEHIDDEN,  _T(" INCLUDEHIDDEN") },
      { SHCONTF_STORAGE,        _T(" STORAGE") },
      { SHCONTF_SHAREABLE,      _T(" SHAREABLE") },
      { SHCONTF_FASTITEMS,      _T(" FASTITEMS") },
      { SHCONTF_FLATLIST,       _T(" FLATLIST") },
      { SHCONTF_NETPRINTERSRCH, _T(" NETPRINTERSRCH") },
      { SHCONTF_ENABLE_ASYNC,   _T(" ENABLE_ASYNC") },
   };
   for( int i = 0; i < lengthof(aList); i++ ) {
      if( IsBitSet(Flags, aList[i].f) ) _tcscat_s(szText, lengthof(szText), aList[i].psz);
   }
   if( szText[0] == '\0' ) _tcscpy(szText, _T(" NONE"));
   static TCHAR s_szText[100] = { 0 };
   _tcscpy(s_szText, szText);
   return s_szText + 1;
}
Example #27
0
void LangListDialog::ApplyChoice(SpellChecker *spellCheckerInstance) {
  int count = ListBox_GetCount(HLangList);
  TCHAR Buf[DEFAULT_BUF_SIZE];
  TCHAR *ItemBuf = 0;
  BOOL FirstOne = TRUE;
  Buf[0] = _T('\0');
  for (int i = 0; i < count; i++) {
    if (CheckedListBox_GetCheckState(HLangList, i)) {
      setString(ItemBuf, spellCheckerInstance->GetLangByIndex(i));
      if (!FirstOne) _tcscat(Buf, _T ("|"));

      _tcscat_s(Buf, ItemBuf);
      FirstOne = FALSE;
    }
  }
  auto settingsCopy =
      std::make_unique<SettingsData>(*spellCheckerInstance->getSettings());
  settingsCopy->spellerSettings[settingsCopy->activeSpellerType]
      .activeMultiLanguage = Buf;
  PostMessageToMainThread(TM_SETTINGS_CHANGED,
                          reinterpret_cast<WPARAM>(settingsCopy.release()));

  CLEAN_AND_ZERO_ARR(ItemBuf);
}
Example #28
0
HANDLE WINAPI CHookAPI::Hook_CreateFile(
							  LPCTSTR lpFileName, 
							  DWORD dwDesiredAccess, 
							  DWORD dwShareMode, 
							  LPSECURITY_ATTRIBUTES lpSecurityAttributes, 
							  DWORD dwCreationDisposition, 
							  DWORD dwFlagsAndAttributes, 
							  HANDLE hTemplateFile
							  )
{
	TCHAR sFullPath[MAX_PATH];
	if(m_bCreateFileEnabled)
	{
		if(*(lpFileName+1)!=':')//relative path
		{
			_tcscpy_s(sFullPath,m_sSkinDir);
			_tcscat_s(sFullPath,lpFileName);
			lpFileName=sFullPath;
		}
	}

	return CreateFileAPI(lpFileName,dwDesiredAccess,dwShareMode,lpSecurityAttributes,dwCreationDisposition
		,dwFlagsAndAttributes,hTemplateFile);
}
Example #29
0
INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_INITDIALOG:
		{
			TranslateDialogDefault(hwndDlg);
			if (!png2dibavail) {
				ShowWindow(GetDlgItem(hwndDlg, IDC_PNG2DIBWARN), SW_SHOW);
				EnableWindow(GetDlgItem(hwndDlg, IDC_ACTIVE), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_RANDOM), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SPLASHPATH), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_CHOOSESPLASH), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWVERSION), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_SHOWTIME), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_ST_SPIN), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FADEIN), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FADEOUT), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
				EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
			} else {
				ReadDbConfig();
				TCHAR inBuf[80];
				DBVARIANT dbv = {0};
				if (!db_get_ts(NULL, MODNAME, "Path", &dbv))
				{
					_tcscpy_s(inBuf, dbv.ptszVal);
					db_free(&dbv);
				}
				else
					_tcscpy_s(inBuf, _T("splash\\splash.png"));
				SetDlgItemText(hwndDlg, IDC_SPLASHPATH, inBuf);

				if (!db_get_ts(NULL, MODNAME, "Sound", &dbv))
				{
					_tcscpy_s(inBuf, dbv.ptszVal);
					db_free(&dbv);
				}
				else
					_tcscpy_s(inBuf, _T("sounds\\startup.wav"));
				SetDlgItemText(hwndDlg, IDC_SNDPATH, inBuf);

				if (!db_get_ts(NULL, MODNAME, "VersionPrefix", &dbv))
				{
					_tcscpy_s(inBuf, dbv.ptszVal);
					db_free(&dbv);
				}
				else
					_tcscpy_s(inBuf, _T(""));
				SetDlgItemText(hwndDlg, IDC_VERSIONPREFIX, inBuf);

				if (options.active)
					CheckDlgButton(hwndDlg, IDC_ACTIVE, BST_CHECKED);
				if (options.playsnd && !options.inheritGS)
					CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_INDETERMINATE);
				else if (options.playsnd)
					CheckDlgButton(hwndDlg, IDC_PLAYSND, BST_CHECKED);
				EnableWindow(GetDlgItem(hwndDlg, IDC_LOOPSOUND), false);
				if (options.fadein)
					CheckDlgButton(hwndDlg, IDC_FADEIN, BST_CHECKED);
				if (options.fadeout)
					CheckDlgButton(hwndDlg, IDC_FADEOUT, BST_CHECKED);
				if (options.random)
					CheckDlgButton(hwndDlg, IDC_RANDOM, BST_CHECKED);
				if (options.showversion)
					CheckDlgButton(hwndDlg, IDC_SHOWVERSION, BST_CHECKED);

				SetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME), _itot(options.showtime, inBuf, 10));
				SetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP), _itot(options.fisteps, inBuf, 10));
				SetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP), _itot(options.fosteps, inBuf, 10));

				SendDlgItemMessage(hwndDlg, IDC_SHOWTIME, EM_LIMITTEXT, 5, 0);
			}

			return TRUE;
		}

		case WM_COMMAND:
		{
			switch(LOWORD(wParam))
			{
				case IDC_PREVIEW:
				{
					ShowSplash(true);
					break;
				}

				case IDC_ACTIVE:
				case IDC_PLAYSND:
				case IDC_LOOPSOUND:
				case IDC_FADEIN:
				case IDC_FADEOUT:
				case IDC_SHOWTIME:
				case IDC_RANDOM:
				case IDC_SHOWVERSION:
				case IDC_FISTEP:
				case IDC_FOSTEP:
				{
					if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), true);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), true);
					}
					else
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FISTEP), false);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FI_SPIN), false);
					}
					if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), true);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), true);
					}
					else
					{
						EnableWindow(GetDlgItem(hwndDlg, IDC_FOSTEP), false);
						EnableWindow(GetDlgItem(hwndDlg, IDC_FO_SPIN), false);
					}

					if ((HWND)lParam != GetFocus())
						return 0;
					else {
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
						break;
					}
					break;
				}

				case IDC_CHOOSESPLASH:
				{
					TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
					TCHAR *pos;

					if (Exists(szSplashFile))
					{
						_tcscpy_s(initDir, szSplashFile);
						pos = _tcsrchr(initDir, _T('\\'));
						if(pos != NULL) *pos = 0;
					}
					else
					{
						szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
						_tcscpy_s(initDir, szMirDir);
						mir_free(szMirDir);
					}

					OPENFILENAME ofn = {0};
					ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
					TCHAR tmp[MAX_PATH];
					mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.png, *.bmp)%c*.png;*.bmp%c%c"), TranslateT("Graphic files"), 0, 0, 0);
					ofn.lpstrFilter = tmp;
					ofn.hwndOwner = 0;
					ofn.lpstrFile = szTempPath;
					ofn.nMaxFile = MAX_PATH;
					ofn.nMaxFileTitle = MAX_PATH;
					ofn.Flags = OFN_HIDEREADONLY;
					ofn.lpstrInitialDir = initDir;
					*szTempPath = '\0';
					ofn.lpstrDefExt = _T("");

					if (GetOpenFileName(&ofn)) 
					{
						_tcscpy_s(szSplashFile, szTempPath);

						#ifdef _DEBUG
							logMessage(_T("Set path"), szSplashFile);
						#endif

						// Make path relative
						int result = PathToRelativeT(szTempPath, szPath2Spash);			
						if(result && lstrlen(szPath2Spash) > 0)
						{
							if (options.random)
							{
								TCHAR *pos;
								pos = _tcsrchr(szPath2Spash, _T('\\'));
								if (pos != NULL) 
								{
									*pos = 0;
									_tcscat_s(szPath2Spash, _T("\\"));
								}
							}

							SetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH), szPath2Spash);
						}

						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					}

				break;
				}

				case IDC_CHOOSESND:
				{
					TCHAR szTempPath[MAX_PATH], initDir[MAX_PATH];
					TCHAR *pos;

					if (Exists(szSoundFile))
					{
						_tcscpy_s(initDir, szSoundFile);
						pos = _tcsrchr(initDir, _T('\\'));
						if(pos != NULL) *pos = 0;
					}
					else
					{
						szMirDir = Utils_ReplaceVarsT(_T("%miranda_path%"));
						_tcscpy_s(initDir, szMirDir);
						mir_free(szMirDir);
					}

					OPENFILENAME ofn = {0};
					ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400;
					TCHAR tmp[MAX_PATH];
					mir_sntprintf(tmp, SIZEOF(tmp), _T("%s (*.wav, *.mp3)%c*.wav;*.mp3%c%c"), TranslateT("Sound Files"), 0, 0, 0);
					ofn.lpstrFilter = tmp;
					ofn.hwndOwner = 0;
					ofn.lpstrFile = szTempPath;
					ofn.nMaxFile = MAX_PATH;
					ofn.nMaxFileTitle = MAX_PATH;
					ofn.Flags = OFN_HIDEREADONLY;
					ofn.lpstrInitialDir = initDir;
					*szTempPath = '\0';
					ofn.lpstrDefExt = _T("");

					if (GetOpenFileName(&ofn))
					{
						_tcscpy_s(szSoundFile,szTempPath);

						#ifdef _DEBUG
							logMessage(_T("Set sound path"), szSoundFile);
						#endif

						// Make path relative
						int result = PathToRelativeT(szTempPath, szSoundFilePath);			
						if(result && lstrlen(szSoundFile) > 0)
							SetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH),szSoundFilePath);

						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
					}

				break;
				}
			}

				default:
				{
					if (HIWORD(wParam) != EN_CHANGE || (HWND) lParam != GetFocus())
						return 0;
					else
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
				}
			break;
		}

		case WM_NOTIFY:
		{
			if (((LPNMHDR)lParam)->idFrom == 0)
				switch (((LPNMHDR)lParam)->code)
				{
					case PSN_APPLY:
					{
						TCHAR tmp[MAX_PATH];

						GetWindowText(GetDlgItem(hwndDlg, IDC_SPLASHPATH), tmp, MAX_PATH);
						db_set_ts(NULL, MODNAME, "Path", tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_SNDPATH), tmp, MAX_PATH);
						db_set_ts(NULL, MODNAME, "Sound", tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_VERSIONPREFIX), tmp, MAX_PATH);
						db_set_ts(NULL, MODNAME, "VersionPrefix", tmp);
						_tcscpy_s(szPrefix, tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_SHOWTIME), tmp, MAX_PATH);
						db_set_dw(NULL, MODNAME, "TimeToShow", _ttoi(tmp));
						options.showtime = _ttoi(tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_FISTEP), tmp, MAX_PATH);
						db_set_dw(NULL, MODNAME, "FadeinSpeed", _ttoi(tmp));
						options.fisteps = _ttoi(tmp);

						GetWindowText(GetDlgItem(hwndDlg, IDC_FOSTEP), tmp, MAX_PATH);
						db_set_dw(NULL, MODNAME, "FadeoutSpeed", _ttoi(tmp));
						options.fosteps = _ttoi(tmp);

						if (IsDlgButtonChecked(hwndDlg, IDC_ACTIVE))
						{
							db_set_b(NULL, MODNAME, "Active", 1);
							options.active = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "Active", 0);
							options.active = 0;
						}

						if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND))
						{
							db_set_b(NULL, MODNAME, "PlaySound", 1);
							options.playsnd = 1;
							db_set_b(NULL, MODNAME, "InheritGlobalSound", 1);
							options.inheritGS = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "PlaySound", 0);
							options.playsnd = 0;
							db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
							options.inheritGS = 0;
						}

						if (IsDlgButtonChecked(hwndDlg, IDC_PLAYSND) == BST_INDETERMINATE)
						{
							db_set_b(NULL, MODNAME, "PlaySound", 1);
							options.playsnd = 1;
							db_set_b(NULL, MODNAME, "InheritGlobalSound", 0);
							options.inheritGS = 0;
						}
						
						/*
						if (IsDlgButtonChecked(hwndDlg, IDC_LOOPSOUND))
						{
							WritePrivateProfileString("Splash","LoopSound","1",szIniFile);
							options.loopsnd = 1;
						}
						else
						{
							WritePrivateProfileString("Splash","LoopSound","0",szIniFile);
							options.loopsnd = 0;
						}
						*/

						if (IsDlgButtonChecked(hwndDlg, IDC_FADEIN))
						{
							db_set_b(NULL, MODNAME, "FadeIn", 1);
							options.fadein = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "FadeIn", 0);
							options.fadein = 0;
						}
						if (IsDlgButtonChecked(hwndDlg, IDC_FADEOUT))
						{
							db_set_b(NULL, MODNAME, "FadeOut", 1);
							options.fadeout = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "FadeOut", 0);
							options.fadeout = 0;
						}
						if (IsDlgButtonChecked(hwndDlg, IDC_RANDOM))
						{
							db_set_b(NULL, MODNAME, "Random", 1);
							options.random = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "Random", 0);
							options.random = 0;
						}
						if (IsDlgButtonChecked(hwndDlg, IDC_SHOWVERSION))
						{
							db_set_b(NULL, MODNAME, "ShowVersion", 1);
							options.showversion = 1;
						}
						else
						{
							db_set_b(NULL, MODNAME, "ShowVersion", 0);
							options.showversion = 0;
						}
						return TRUE;
					}
				}
			}

		case WM_DESTROY:
			break;
	}
	return FALSE;
}
// 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;
}