extern "C" __declspec(dllexport) int Load(void) { mir_getLP(&pluginInfo); InitAssocList(); InitDde(); /* installation */ InstallFile(_T("AssocMgr-Readme.txt"),_T("Docs\\")); InstallFile(_T("AssocMgr-License.txt"),_T("Docs\\")); InstallFile(_T("AssocMgr-SDK.zip"),_T("Docs\\")); hHookModulesLoaded=HookEvent(ME_SYSTEM_MODULESLOADED,AssocMgrModulesLoaded); return 0; }
static int InstallAllFiles( addons_storage_t *p_this, const addon_entry_t *p_entry ) { const addon_file_t *p_file; char *psz_dest; if ( p_entry->files.i_size < 1 ) return VLC_EGENERIC; FOREACH_ARRAY( p_file, p_entry->files ) switch( p_file->e_filetype ) { case ADDON_EXTENSION: case ADDON_PLAYLIST_PARSER: case ADDON_SERVICE_DISCOVERY: case ADDON_INTERFACE: case ADDON_META: case ADDON_SKIN2: { if ( strstr( p_file->psz_filename, ".." ) ) return VLC_EGENERIC; char *psz_translated_filename = strdup( p_file->psz_filename ); if ( !psz_translated_filename ) return VLC_ENOMEM; char *tmp = psz_translated_filename; while (*tmp++) if ( *tmp == '/' ) *tmp = DIR_SEP_CHAR; char *psz_dir = getAddonInstallDir( p_file->e_filetype ); if ( !psz_dir || asprintf( &psz_dest, "%s"DIR_SEP"%s", psz_dir, psz_translated_filename ) < 1 ) { free( psz_dir ); free( psz_translated_filename ); return VLC_EGENERIC; } free( psz_translated_filename ); free( psz_dir ); if ( InstallFile( p_this, p_file->psz_download_uri, psz_dest ) != VLC_SUCCESS ) { free( psz_dest ); return VLC_EGENERIC; } free( psz_dest ); break; } /* Ignore all other unhandled files */ case ADDON_UNKNOWN: case ADDON_PLUGIN: case ADDON_OTHER: default: break; } FOREACH_END() return VLC_SUCCESS; }
void UpdateDlg::OnDownloadEnded(wxCommandEvent& event) { UpdateStatus(_("Download finished: ") + event.GetString()); XRCCTRL(*this, "lblProgress", wxStaticText)->SetLabel(_T("")); m_LastBlockSize = 0; if (m_HasUpdated && event.GetInt() == 0) { UpdateRec* rec = GetRecFromListView(); if (rec) { if (rec->bytes != m_CurrFileSize) wxMessageBox(_("File size mismatch for ") + event.GetString() + _("!\n\n" "This, usually, means one of three things:\n" "1) The reported size in the update list is wrong. The DevPak might still be valid.\n" "2) The file's location returned a web error-page. Invalid DevPak...\n" "3) The file is corrupt...\n\n" "You can try to install it anyway. If it is not a valid DevPak, the operation will fail."), _("Warning"), wxICON_WARNING); } if (rec && rec->installable && wxMessageBox(_("Do you want to install ") + event.GetString() + _(" now?"), _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxYES) InstallFile(); else if (rec && rec->title == _T("WebUpdate Mirrors list")) InstallMirrors(GetPackagePath() + rec->local_file); } m_CurrFileSize = 0; }
BOOL APIENTRY InstallAVIFileDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_INITDIALOG: { HWND hwndListbox = GetDlgItem(hDlg, IDC_ACTIONLIST); SetWindowText(hDlg, "Install AVIFile frameclient"); ListboxAddf(hwndListbox, "Copy VDREMOTE.DLL to %s\\SYSTEM\\VDREMOTE.DLL", g_szWinPath); ListboxAddf(hwndListbox, "Copy VDSRVLNK.DLL to %s\\SYSTEM\\VDSRVLNK.DLL", g_szWinPath); ListboxAddf(hwndListbox, "Add VDRemote class and AVIFile entries to Registry"); } return TRUE; case WM_COMMAND: switch(LOWORD(wParam)) { case IDOK: if ( InstallFile("vdremote.dll","%s\\system\\vdremote.dll",g_szWinPath) && InstallFile("vdsvrlnk.dll","%s\\system\\vdsvrlnk.dll",g_szWinPath) && InstallRegStr(HKEY_CLASSES_ROOT,"CLSID\\{894288e0-0948-11d2-8109-004845000eb5}",NULL,"VirtualDub link handler") && InstallRegStr(HKEY_CLASSES_ROOT,"CLSID\\{894288e0-0948-11d2-8109-004845000eb5}\\InprocServer32",NULL,"vdremote.dll") && InstallRegStr(HKEY_CLASSES_ROOT,"CLSID\\{894288e0-0948-11d2-8109-004845000eb5}\\InprocServer32","ThreadingModel","Apartment") && InstallRegStr(HKEY_CLASSES_ROOT,"CLSID\\{894288e0-0948-11d2-8109-004845000eb5}\\InprocServer32\\AVIFile",NULL,"1") && InstallRegStr(HKEY_CLASSES_ROOT,"AVIFile\\Extensions\\VDR",NULL,"{894288e0-0948-11d2-8109-004845000eb5}") && InstallRegStr(HKEY_CLASSES_ROOT,"AVIFile\\RIFFHandlers\\VDRM",NULL,"{894288e0-0948-11d2-8109-004845000eb5}") ) MessageBox(hDlg, "AVIFile frameclient install successful.", "VirtualDub Setup", MB_OK); else MessageBox(hDlg, "AVIFile frameclient install failed.", "VirtualDub Setup", MB_OK); EndDialog(hDlg, TRUE); return TRUE; case IDCANCEL: EndDialog(hDlg, FALSE); return TRUE; } } return FALSE; }
BOOL CInstall::InstallFiles(BOOL bNoCopy, BOOL *pbQuit) { char szLogNew[MAXSTR]; AddMessage(bNoCopy ? "Checking" : "Copying"); AddMessage(" files listed in "); AddMessage(m_szFileList); AddMessage("\n"); // Open list of files SetCurrentDirectory(m_szSourceDir); FILE *f = fopen(m_szFileList, "r"); if (f == (FILE *)NULL) { AddMessage("Failed to open \042"); AddMessage(m_szFileList); AddMessage("\042\n"); return FALSE; } // skip application and directory name fgets(szLogNew, sizeof(szLogNew), f); fgets(szLogNew, sizeof(szLogNew), f); // Create target log m_fLogNew = MakeTemp(m_szFileNew); if (!m_fLogNew) { AddMessage("Failed to create FileNew temporary file\n"); return FALSE; } // Copy files char line[MAXSTR]; while (fgets(line, sizeof(line), f) != (char *)NULL) { if (*pbQuit) return FALSE; if (*line) line[strlen(line)-1] = '\0'; if (!InstallFile(line, bNoCopy)) { fclose(f); fclose(m_fLogNew); return FALSE; } } fclose(f); fclose(m_fLogNew); m_fLogNew = NULL; return TRUE; }
void UpdateDlg::DownloadFile(bool dontInstall) { UpdateStatus(_("Please wait...")); UpdateRec* rec = GetRecFromListView(); if (!rec) { wxMessageBox(_("No file selected!"), _("Error"), wxICON_ERROR); UpdateStatus(_("Ready"), 0, 0); return; } if (rec->version == rec->installed_version) { if (wxMessageBox(_("You seem to have installed the latest version.\nAre you sure you want to proceed?"), _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxNO) return; } if (!CreateDirRecursively(GetPackagePath())) { wxMessageBox(_("Can't create directory ") + GetPackagePath(), _("Error"), wxICON_ERROR); return; } if (wxFileExists(GetPackagePath() + rec->local_file)) { if (wxMessageBox(_("This file already exists!\nAre you sure you want to download it again?"), _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxNO && rec->installable) { if (!dontInstall && wxMessageBox(_("Do you want to force-install it?"), _("Confirmation"), wxICON_QUESTION | wxYES_NO) == wxYES) InstallFile(); return; } } m_Net.SetServer(rec->remote_server); EnableButtons(false); if (!m_Net.DownloadFile(rec->remote_file, GetPackagePath() + rec->local_file)) { rec->downloaded = false; UpdateStatus(_("Error downloading file: ") + rec->remote_server + _T(" > ") + rec->remote_file, 0, 0); return; } else rec->downloaded = true; UpdateStatus(_("Ready"), 0, 0); EnableButtons(); }
BOOL CALLBACK DlgMain_InstallFiles(HWND hWnd) { HCURSOR hCursor = SetCursor(LoadCursor(0, IDC_WAIT)); HINSTANCE hModule = GetModuleHandle(0); int count = SendDlgItemMessage(hWnd, 100, LB_GETCOUNT , 0, 0); int index = 0; TCHAR path[8 * MAX_PATH]; int cchPath; if (IsDlgButtonChecked(hWnd, 201)) { cchPath = GetSystemDirectory(path, 4 * MAX_PATH); } else { cchPath = GetDlgItemText(hWnd, 203, path, 5 * MAX_PATH); int cchName = PathGetTailLength(path); if (cchName < cchPath) { cchPath -= cchName; } } if (cchPath != 3 || path[1] != ':') { path[cchPath++] = '\\'; } LPTSTR name = path + cchPath; while (index < count) { if (SendDlgItemMessage(hWnd, 100, LB_GETSEL, index, 0)) { int cchName = SendDlgItemMessage(hWnd, 100, LB_GETTEXT, index, (LPARAM)name); InstallFile(hWnd, name, "Merge7z", path, cchPath); } ++index; } if (IsDlgButtonChecked(hWnd, 205)) { EnumResourceNames(GetModuleHandle(0), "7-ZIP", fnInstallFiles, (LONG)hWnd); } SetCursor(hCursor); return TRUE; }
BOOL CALLBACK fnInstallFiles(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LONG lParam) { HWND hWnd = (HWND)lParam; TCHAR path[8 * MAX_PATH]; int cchPath = GetDlgItemText(hWnd, 203, path, 5 * MAX_PATH); int cchName = PathGetTailLength(path); if (cchName < cchPath) { cchPath -= cchName; } if (cchPath != 3 || path[1] != ':') { path[cchPath++] = '\\'; } TCHAR acName[MAX_PATH]; if (ATOM aName = FindAtom(lpName)) { GetAtomName(aName, lpName = acName, sizeof acName); } InstallFile(hWnd, lpName, lpType, path, cchPath); return TRUE; }
HRESULT Install( BOOL bRegisterUninstaller, BOOL bCopyFile ) { TCHAR szCurrentDllPath[MAX_PATH << 1]; GetModuleFileName(g_hModThisDll, szCurrentDllPath, countof(szCurrentDllPath)); TCHAR szSysDir[MAX_PATH + 0x20]; UINT uSize = GetSystemDirectory(szSysDir, MAX_PATH); if (uSize && uSize < MAX_PATH) { LPTSTR lpszPath = szSysDir; LPTSTR lpszPathAppend = lpszPath + uSize; if (*(lpszPathAppend - 1) != TEXT('\\')) *lpszPathAppend++ = TEXT('\\'); LPTSTR lpszTargetPath = (bCopyFile) ? lpszPath : szCurrentDllPath; if ( (!bCopyFile || InstallFile(szCurrentDllPath, lpszTargetPath, lpszPathAppend)) && DllRegisterServerEx(lpszTargetPath) == S_OK ) { HKEY hKey, hKeySub; // Associate file extensions for (UINT i = 0; i < countof(g_szHashExtsTab); ++i) { if (hKey = RegOpen(HKEY_CLASSES_ROOT, g_szHashExtsTab[i], NULL, TRUE)) { RegSetSZ(hKey, NULL, PROGID_STR_HashCheck); RegSetSZ(hKey, TEXT("PerceivedType"), TEXT("text")); if (hKeySub = RegOpen(hKey, TEXT("PersistentHandler"), NULL, TRUE)) { RegSetSZ(hKeySub, NULL, TEXT("{5e941d80-bf96-11cd-b579-08002b30bfeb}")); RegCloseKey(hKeySub); } RegCloseKey(hKey); } } // Disassociate former file extensions; see the comment in DllUnregisterServer for // why this step is skipped for Wow64 processes if (!Wow64CheckProcess()) { for (UINT i = 0; i < countof(szFormerHashExtsTab); ++i) { HKEY hKey; if (hKey = RegOpen(HKEY_CLASSES_ROOT, szFormerHashExtsTab[i], NULL, FALSE)) { TCHAR szTemp[countof(PROGID_STR_HashCheck)]; RegGetSZ(hKey, NULL, szTemp, sizeof(szTemp)); if (_tcscmp(szTemp, PROGID_STR_HashCheck) == 0) RegDeleteValue(hKey, NULL); RegCloseKey(hKey); } } } // Uninstaller entries RegDelete(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s"), CLSNAME_STR_HashCheck); if (bRegisterUninstaller && (hKey = RegOpen(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s"), CLSNAME_STR_HashCheck, TRUE))) { TCHAR szUninstall[MAX_PATH << 1]; StringCchPrintf(szUninstall, countof(szUninstall), TEXT("regsvr32.exe /u /i /n \"%s\""), lpszTargetPath); static const TCHAR szURLFull[] = TEXT("https://github.com/gurnec/HashCheck/issues"); TCHAR szURLBase[countof(szURLFull)]; SSStaticCpy(szURLBase, szURLFull); szURLBase[35] = 0; // strlen("https://github.com/gurnec/HashCheck") RegSetSZ(hKey, TEXT("DisplayIcon"), lpszTargetPath); RegSetSZ(hKey, TEXT("DisplayName"), TEXT(HASHCHECK_NAME_STR)); RegSetSZ(hKey, TEXT("DisplayVersion"), TEXT(HASHCHECK_VERSION_STR)); RegSetDW(hKey, TEXT("EstimatedSize"), 1073); RegSetSZ(hKey, TEXT("HelpLink"), szURLFull); RegSetDW(hKey, TEXT("NoModify"), 1); RegSetDW(hKey, TEXT("NoRepair"), 1); RegSetSZ(hKey, TEXT("UninstallString"), szUninstall); RegSetSZ(hKey, TEXT("URLInfoAbout"), szURLBase); RegSetSZ(hKey, TEXT("URLUpdateInfo"), TEXT("https://github.com/gurnec/HashCheck/releases/latest")); RegCloseKey(hKey); } return(S_OK); } // if copied & registered } // if valid sysdir return(E_FAIL); }
void UpdateDlg::OnInstall(wxCommandEvent& event) { InstallFile(); }