Esempio n. 1
0
codeINSTALL_EXIT Install_Exit(
    HWND    hwndParent,
    LPCTSTR pszInstallDir,
    WORD    cFailedDirs,
    WORD    cFailedFiles,
    WORD    cFailedRegKeys,
    WORD    cFailedRegVals,
    WORD    cFailedShortcuts)
{
	// TODO: Add custom installation code here

	// To exit the installation DLL normally, 
	// return codeINSTALL_EXIT_DONE
	// To unistall the application after the function exits,
	// return codeINSTALL_EXIT_UNINSTALL   Ошибка при установке на wm 6.5 с разноязычной прошивкой 

	TCHAR szShortcutPath[MAX_PATH];
	TCHAR szOutFile[MAX_PATH];
	TCHAR szOutFileLink[MAX_PATH];
	HKEY hKey, hSubKey;
	HRESULT hr = S_OK;

	SHGetSpecialFolderPath(0, szShortcutPath, CSIDL_PROGRAMS, false); 
	wsprintf(szOutFile,_T("\"%s\\%s\""), pszInstallDir, _T("VKontakteWM.exe"));
	wsprintf(szOutFileLink,_T("%s\\%s"), szShortcutPath, _T("ВКонтакте.lnk"));
	SHCreateShortcut(szOutFileLink, szOutFile);

	hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Security\\Shell\\StartInfo\\Start\\ВКонтакте.lnk"), 0, 0, &hKey);
	if(hr != ERROR_SUCCESS)
	{
		RegCloseKey(hKey);
		hr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT("Security\\Shell\\StartInfo\\Start"), 0, 0, &hKey);
		hr = RegCreateKeyEx(hKey,
			TEXT("ВКонтакте.lnk"), 0, NULL, REG_OPTION_NON_VOLATILE, NULL, NULL, &hSubKey, NULL);
		RegCloseKey(hKey);
		hKey = hSubKey;
	}

	wsprintf(szOutFile,_T("%s\\%s"), pszInstallDir, _T("vkontakte.png"));
	hr = RegSetValueEx(hKey, TEXT("Icon"), 0, REG_SZ, (LPBYTE)szOutFile, 200);
	RegCloseKey(hKey);
      
	return codeINSTALL_EXIT_DONE;
}
Esempio n. 2
0
bool QFSFileEngine::link(const QString &newName)
{
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
#if !defined(QT_NO_LIBRARY)
    bool ret = false;

    QString linkName = newName;
    //### assume that they add .lnk

    IShellLink *psl;
    bool neededCoInit = false;

    HRESULT hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);

    if (hres == CO_E_NOTINITIALIZED) { // COM was not initialized
        neededCoInit = true;
        CoInitialize(NULL);
        hres = CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void **)&psl);
    }

    if (SUCCEEDED(hres)) {
        hres = psl->SetPath((wchar_t *)fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\')).utf16());
        if (SUCCEEDED(hres)) {
            hres = psl->SetWorkingDirectory((wchar_t *)fileName(AbsolutePathName).replace(QLatin1Char('/'), QLatin1Char('\\')).utf16());
            if (SUCCEEDED(hres)) {
                IPersistFile *ppf;
                hres = psl->QueryInterface(IID_IPersistFile, (void **)&ppf);
                if (SUCCEEDED(hres)) {
                    hres = ppf->Save((wchar_t*)linkName.utf16(), TRUE);
                    if (SUCCEEDED(hres))
                         ret = true;
                    ppf->Release();
                }
            }
        }
        psl->Release();
    }
    if (!ret)
        setError(QFile::RenameError, qt_error_string());

    if (neededCoInit)
        CoUninitialize();

    return ret;
#else
    Q_UNUSED(newName);
    return false;
#endif // QT_NO_LIBRARY
#elif defined(Q_OS_WINCE) && !defined(QT_NO_WINCE_SHELLSDK)
    QString linkName = newName;
    linkName.replace(QLatin1Char('/'), QLatin1Char('\\'));
    if (!linkName.endsWith(QLatin1String(".lnk")))
        linkName += QLatin1String(".lnk");
    QString orgName = fileName(AbsoluteName).replace(QLatin1Char('/'), QLatin1Char('\\'));
    // Need to append on our own
    orgName.prepend(QLatin1Char('"'));
    orgName.append(QLatin1Char('"'));
    bool ret = SUCCEEDED(SHCreateShortcut((wchar_t*)linkName.utf16(), (wchar_t*)orgName.utf16()));
    if (!ret)
        setError(QFile::RenameError, qt_error_string());
    return ret;
#else // Q_OS_WINCE && !QT_NO_WINCE_SHELLSDK
    Q_UNUSED(newName);
    Q_UNIMPLEMENTED();
    return false;
#endif // Q_OS_WINRT
}