LONG msi_reg_set_subkey_val( HKEY hkey, LPCWSTR path, LPCWSTR name, LPCWSTR val ) { HKEY hsubkey = 0; LONG r; r = RegCreateKeyW( hkey, path, &hsubkey ); if (r != ERROR_SUCCESS) return r; r = msi_reg_set_val_str( hsubkey, name, val ); RegCloseKey( hsubkey ); return r; }
/* Wrapper around RegSetValueExW */ LONG msi_reg_set_val( HKEY hkey, LPCWSTR name, DWORD reserved, DWORD type, const BYTE *lpData, DWORD cbData ) { if (type == REG_SZ) return msi_reg_set_val_str(hkey,name,(LPCWSTR)lpData); else if (type == REG_EXPAND_SZ) return msi_reg_set_val_expand_str(hkey,name,(LPCWSTR)lpData); else if (type == REG_MULTI_SZ) return msi_reg_set_val_multi_str(hkey,name,(LPCWSTR)lpData); else return RegSetValueExW( hkey, name, reserved, type, lpData, cbData ); }
static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; LPWSTR name; LPCWSTR filename; MSIFILE *file; MSICOMPONENT *comp; HKEY hkey1, hkey2; MSIRECORD *uirow; LPWSTR uipath, p; filename = MSI_RecordGetString( row, 1 ); file = msi_get_loaded_file( package, filename ); if (!file) { WARN("unable to find file %s\n", debugstr_w(filename)); return ERROR_SUCCESS; } comp = msi_get_loaded_component( package, file->Component->Component ); if (!comp) { WARN("unable to find component %s\n", debugstr_w(file->Component->Component)); return ERROR_SUCCESS; } comp->Action = msi_get_component_action( package, comp ); if (comp->Action != INSTALLSTATE_LOCAL) { TRACE("component not scheduled for installation %s\n", debugstr_w(comp->Component)); return ERROR_SUCCESS; } RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1); RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont2,&hkey2); if (MSI_RecordIsNull(row,2)) name = font_name_from_file( file->TargetPath ); else name = msi_dup_record_field(row,2); if (name) { msi_reg_set_val_str( hkey1, name, file->TargetPath); msi_reg_set_val_str( hkey2, name, file->TargetPath); } msi_free(name); RegCloseKey(hkey1); RegCloseKey(hkey2); /* the UI chunk */ uirow = MSI_CreateRecord( 1 ); uipath = strdupW( file->TargetPath ); p = strrchrW(uipath,'\\'); if (p) p++; else p = uipath; MSI_RecordSetStringW( uirow, 1, p ); msi_ui_actiondata( package, szRegisterFonts, uirow ); msiobj_release( &uirow->hdr ); msi_free( uipath ); /* FIXME: call msi_ui_progress? */ return ERROR_SUCCESS; }
static UINT ITERATE_RegisterFonts(MSIRECORD *row, LPVOID param) { MSIPACKAGE *package = param; LPWSTR name; LPCWSTR filename; MSIFILE *file; static const WCHAR regfont1[] = {'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s',' ','N','T','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'F','o','n','t','s',0}; static const WCHAR regfont2[] = {'S','o','f','t','w','a','r','e','\\', 'M','i','c','r','o','s','o','f','t','\\', 'W','i','n','d','o','w','s','\\', 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\', 'F','o','n','t','s',0}; HKEY hkey1; HKEY hkey2; MSIRECORD *uirow; LPWSTR uipath, p; filename = MSI_RecordGetString( row, 1 ); file = get_loaded_file( package, filename ); if (!file) { ERR("Unable to load file\n"); return ERROR_SUCCESS; } /* check to make sure that component is installed */ if (!ACTION_VerifyComponentForAction( file->Component, INSTALLSTATE_LOCAL)) { TRACE("Skipping: Component not scheduled for install\n"); return ERROR_SUCCESS; } RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont1,&hkey1); RegCreateKeyW(HKEY_LOCAL_MACHINE,regfont2,&hkey2); if (MSI_RecordIsNull(row,2)) name = load_ttfname_from( file->TargetPath ); else name = msi_dup_record_field(row,2); if (name) { msi_reg_set_val_str( hkey1, name, file->TargetPath); msi_reg_set_val_str( hkey2, name, file->TargetPath); } msi_free(name); RegCloseKey(hkey1); RegCloseKey(hkey2); /* the UI chunk */ uirow = MSI_CreateRecord( 1 ); uipath = strdupW( file->TargetPath ); p = strrchrW(uipath,'\\'); if (p) p++; else p = uipath; MSI_RecordSetStringW( uirow, 1, p ); ui_actiondata( package, szRegisterFonts, uirow); msiobj_release( &uirow->hdr ); msi_free( uipath ); /* FIXME: call ui_progress? */ return ERROR_SUCCESS; }