Apply [#26044] Windows thumbnails and improved filetype registration

submitted by Tom Edwards
Fix [#25473] 64bit Windows installer for version 2.56 is not working
patch submitted by Caleb (Dobz)

The thumbnail patch adds a thumb handler DLL that adds .blend thumbnail support in Windows Explorer. A -r option is added to do registration in background. The patch also improves icon building and metadata for blender.exe.

Caleb fixes and cleans up our installer to an acceptable state. The patch uses the new -r option to do the .blend extension and thumbnailer registration.

Thanks to both Caleb and Tom for their efforts!
This commit is contained in:
Nathan Letwory 2011-03-29 13:00:03 +00:00
parent 74e044065b
commit e4e78d4754
11 changed files with 266 additions and 96 deletions

@ -153,13 +153,11 @@ if cc:
if cxx: if cxx:
env['CXX'] = cxx env['CXX'] = cxx
if env['CC'] in ['cl', 'cl.exe'] and sys.platform=='win32': if sys.platform=='win32':
if bitness == 64: if env['CC'] in ['cl', 'cl.exe']:
platform = 'win64-vc' platform = 'win64-vc' if bitness == 64 else 'win32-vc'
else: elif env['CC'] in ['gcc']:
platform = 'win32-vc' platform = 'win32-mingw'
elif env['CC'] in ['gcc'] and sys.platform=='win32':
platform = 'win32-mingw'
env.SConscriptChdir(0) env.SConscriptChdir(0)
@ -197,6 +195,10 @@ else:
opts = btools.read_opts(env, optfiles, B.arguments) opts = btools.read_opts(env, optfiles, B.arguments)
opts.Update(env) opts.Update(env)
if sys.platform=='win32':
if bitness==64:
env.Append(CFLAGS=['-DWIN64']) # -DWIN32 needed too, as it's used all over to target Windows generally
if not env['BF_FANCY']: if not env['BF_FANCY']:
B.bc.disable() B.bc.disable()
@ -641,6 +643,16 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
'${BF_FFMPEG_LIBPATH}/avdevice-52.dll', '${BF_FFMPEG_LIBPATH}/avdevice-52.dll',
'${BF_FFMPEG_LIBPATH}/avutil-50.dll', '${BF_FFMPEG_LIBPATH}/avutil-50.dll',
'${BF_FFMPEG_LIBPATH}/swscale-0.dll'] '${BF_FFMPEG_LIBPATH}/swscale-0.dll']
# Since the thumb handler is loaded by Explorer, architecture is
# strict: the x86 build fails on x64 Windows. We need to ship
# both builds in x86 packages.
if bitness == 32:
dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb.dll')
dllsources.append('${LCGDIR}/thumbhandler/lib/BlendThumb64.dll')
dllsources.append('#source/icons/blender.exe.manifest')
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources) windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
allinstall += windlls allinstall += windlls

@ -6,19 +6,20 @@
; Requires the MoreInfo plugin - http://nsis.sourceforge.net/MoreInfo_plug-in ; Requires the MoreInfo plugin - http://nsis.sourceforge.net/MoreInfo_plug-in
; ;
SetCompressor /SOLID lzma
Name "Blender [VERSION]"
!define MULTIUSER_EXECUTIONLEVEL Admin
!include "MUI.nsh" !include "MUI.nsh"
!include "WinVer.nsh" !include "WinVer.nsh"
!include "FileFunc.nsh" !include "FileFunc.nsh"
!include "WordFunc.nsh" !include "WordFunc.nsh"
!include "nsDialogs.nsh" !include "nsDialogs.nsh"
!include "MultiUser.nsh"
!include "x64.nsh" !include "x64.nsh"
RequestExecutionLevel user
SetCompressor /SOLID lzma
Name "Blender [VERSION]"
!define MUI_ABORTWARNING !define MUI_ABORTWARNING
!define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Blender. It is recommended that you close all other applications before starting Setup." !define MUI_WELCOMEPAGE_TEXT "This wizard will guide you through the installation of Blender. It is recommended that you close all other applications before starting Setup."
@ -60,21 +61,17 @@ UninstallIcon "[RELDIR]\00.installer.ico"
;Language Strings ;Language Strings
;Description ;Description
LangString DESC_SecCopyUI ${LANG_ENGLISH} "Copy all required files to the application folder." LangString DESC_InstallFiles ${LANG_ENGLISH} "Copy all required files to the application folder."
LangString DESC_Section2 ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)" LangString DESC_StartMenu ${LANG_ENGLISH} "Add shortcut items to the Start Menu. (Recommended)"
LangString DESC_Section3 ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop." LangString DESC_DesktopShortcut ${LANG_ENGLISH} "Add a shortcut to Blender on your desktop."
LangString DESC_Section4 ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc." LangString DESC_BlendRegister ${LANG_ENGLISH} "Blender can register itself with .blend files to allow double-clicking from Windows Explorer, etc."
LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location" LangString TEXT_IO_TITLE ${LANG_ENGLISH} "Specify User Data Location"
;-------------------------------- ;--------------------------------
;Data ;Data
Caption "Blender [VERSION] Installer" Caption "Blender [VERSION] Installer"
OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe" OutFile "[DISTDIR]\..\blender-[VERSION]-windows[BITNESS].exe"
;InstallDir "$PROGRAMFILES[BITNESS]\Blender Foundation\Blender" InstallDir $INSTDIR ; $INSTDIR is set inside .onInit
; Install to user profile dir. While it is non-standard, it allows
; users to install without having to have the installer run in elevated mode.
InstallDir "$PROFILE\Blender Foundation\Blender"
BrandingText "Blender Foundation | http://www.blender.org" BrandingText "Blender Foundation | http://www.blender.org"
ComponentText "This will install Blender [VERSION] on your computer." ComponentText "This will install Blender [VERSION] on your computer."
@ -85,7 +82,7 @@ SilentUnInstall normal
Var BLENDERHOME Var BLENDERHOME
Var SHORTVERSION ; This is blender_version_decimal() from path_util.c Var SHORTVERSION ; This is blender_version_decimal() from path_util.c
; custom controls ; Custom controls
Var HWND Var HWND
Var HWND_APPDATA Var HWND_APPDATA
@ -94,7 +91,23 @@ Var HWND_HOMEDIR
Function .onInit Function .onInit
ClearErrors ClearErrors
!insertmacro MULTIUSER_INIT ; Checks if user has admin rights
StrCpy $SHORTVERSION "[SHORTVERSION]" StrCpy $SHORTVERSION "[SHORTVERSION]"
${If} ${RunningX64}
${If} "[BITNESS]" == "32"
${OrIf} "[BITNESS]" == "-mingw"
StrCpy $INSTDIR "$PROGRAMFILES32\Blender Foundation\Blender" ; Can't use InstallDir inside Section
${ElseIf} "[BITNESS]" == "64"
StrCpy $INSTDIR "$PROGRAMFILES64\Blender Foundation\Blender"
${EndIf}
${Else}
StrCpy $INSTDIR "$PROGRAMFILES\Blender Foundation\Blender"
${EndIf}
FunctionEnd
Function un.onInit
!insertmacro MULTIUSER_UNINIT
FunctionEnd FunctionEnd
Function DataLocation Function DataLocation
@ -105,12 +118,12 @@ Function DataLocation
Abort Abort
${EndIf} ${EndIf}
${NSD_CreateLabel} 0 0 100% 12u "Please specify where you wish to install Blender's user data files." ${NSD_CreateLabel} 0 0 100% 24u "Please specify where you wish to install Blender's user data files. Be aware that if you choose to use your Application Data directory, your preferences and scripts will only be accessible by the current user account."
${NSD_CreateRadioButton} 0 20 100% 12u "Use the Application Data directory" ${NSD_CreateRadioButton} 0 50 100% 12u "Use Application Data directory (recommended)"
Pop $HWND_APPDATA Pop $HWND_APPDATA
${NSD_CreateRadioButton} 0 50 100% 12u "Use the installation directory (ie. location chosen to install blender.exe)." ${NSD_CreateRadioButton} 0 80 100% 12u "Use installation directory"
Pop $HWND_INSTDIR Pop $HWND_INSTDIR
${NSD_CreateRadioButton} 0 80 100% 12u "I have defined a %HOME% variable, please install files here." ${NSD_CreateRadioButton} 0 110 100% 12u "I have defined a %HOME% variable, please install files there"
Pop $HWND_HOMEDIR Pop $HWND_HOMEDIR
${If} ${AtMostWinME} ${If} ${AtMostWinME}
@ -128,7 +141,9 @@ FunctionEnd
Function DataLocationOnLeave Function DataLocationOnLeave
${NSD_GetState} $HWND_APPDATA $R0 ${NSD_GetState} $HWND_APPDATA $R0
${If} $R0 == "1" ${If} $R0 == "1"
SetShellVarContext current
StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender" StrCpy $BLENDERHOME "$APPDATA\Blender Foundation\Blender"
SetShellVarContext all
${Else} ${Else}
${NSD_GetState} $HWND_INSTDIR $R0 ${NSD_GetState} $HWND_INSTDIR $R0
${If} $R0 == "1" ${If} $R0 == "1"
@ -142,15 +157,15 @@ Function DataLocationOnLeave
${EndIf} ${EndIf}
FunctionEnd FunctionEnd
Section "Blender-[VERSION] (required)" SecCopyUI Section "Blender [VERSION] (required)" InstallFiles
SectionIn RO SectionIn RO
; Set output path to the installation directory. ; Set output path to the installation directory.
SetOutPath $INSTDIR SetOutPath $INSTDIR
; the contents of Blender installation root dir ; The contents of Blender installation root dir
[ROOTDIRCONTS] [ROOTDIRCONTS]
; all datafiles (python, scripts, config) ; All datafiles (python, scripts, config)
[DODATAFILES] [DODATAFILES]
SetOutPath $INSTDIR SetOutPath $INSTDIR
@ -162,13 +177,19 @@ Section "Blender-[VERSION] (required)" SecCopyUI
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME" WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" "$BLENDERHOME"
WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]" WriteRegStr HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" "[SHORTVERSION]"
; Write the uninstall keys for Windows ; Write the uninstall keys for Windows
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender (remove only)" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayName" "Blender"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "Publisher" "Blender Foundation"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "URLInfoAbout" "http://www.blender.org/"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayVersion" "[VERSION]"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "DisplayIcon" "$INSTDIR\blender.exe"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" "NoRepair " 1
WriteUninstaller "uninstall.exe" WriteUninstaller "uninstall.exe"
SectionEnd SectionEnd
Section "Add Start Menu shortcuts" Section2 Section "Add Start Menu Shortcuts" StartMenu
SetShellVarContext all SetShellVarContext all
CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\" CreateDirectory "$SMPROGRAMS\Blender Foundation\Blender\"
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
@ -176,45 +197,38 @@ Section "Add Start Menu shortcuts" Section2
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Readme.lnk" "$INSTDIR\readme.html" "" "" 0
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\Copyright.lnk" "$INSTDIR\Copyright.txt" "" "$INSTDIR\copyright.txt" 0
CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0 CreateShortCut "$SMPROGRAMS\Blender Foundation\Blender\GPL-license.lnk" "$INSTDIR\GPL-license.txt" "" "$INSTDIR\GPL-license.txt" 0
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
SectionEnd SectionEnd
Section "Add Desktop Blender-[VERSION] shortcut" Section3 Section "Add Desktop Shortcut" DesktopShortcut
CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0 CreateShortCut "$DESKTOP\Blender.lnk" "$INSTDIR\blender.exe" "" "$INSTDIR\blender.exe" 0
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; refresh icons
SectionEnd SectionEnd
Section "Open .blend files with Blender-[VERSION]" Section4 Section "Open .blend files with Blender" BlendRegister
ExecWait '"$INSTDIR\blender.exe" -r'
${If} ${RunningX64}
SetRegView 64
${EndIf}
WriteRegStr HKCR ".blend" "" "blendfile"
WriteRegStr HKCR "blendfile" "" "Blender .blend File"
WriteRegStr HKCR "blendfile\shell" "" "open"
WriteRegStr HKCR "blendfile\DefaultIcon" "" $INSTDIR\blender.exe,1
WriteRegStr HKCR "blendfile\shell\open\command" "" \
'"$INSTDIR\blender.exe" "%1"'
SectionEnd SectionEnd
UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit next to continue." UninstallText "This will uninstall Blender [VERSION], and all installed files. Before continuing make sure you have created backup of all the files you may want to keep: startup.blend, bookmarks.txt, recent-files.txt. Hit 'Uninstall' to continue."
Section "Uninstall" Section "Uninstall"
; remove registry keys ; Remove registry keys
${If} ${RunningX64} ${If} ${RunningX64}
SetRegView 64 SetRegView 64
${EndIf} ${EndIf}
ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir" ReadRegStr $BLENDERHOME HKLM "SOFTWARE\BlenderFoundation" "ConfigData_Dir"
ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion" ReadRegStr $SHORTVERSION HKLM "SOFTWARE\BlenderFoundation" "ShortVersion"
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Blender" DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Blender"
DeleteRegKey HKLM "SOFTWARE\BlenderFoundation" DeleteRegKey HKLM "SOFTWARE\BlenderFoundation"
DeleteRegKey HKCR ".blend"
DeleteRegKey HKCR "blendfile"
DeleteRegKey HKCR "CLSID\{D45F043D-F17F-4e8a-8435-70971D9FA46D}"
SetShellVarContext all SetShellVarContext all
; remove files ; Remove files
[DELROOTDIRCONTS] [DELROOTDIRCONTS]
; remove bundled python
RmDir /r $INSTDIR\$SHORTVERSION\python
Delete "$INSTDIR\uninstall.exe" Delete "$INSTDIR\uninstall.exe"
MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove MessageBox MB_YESNO "Recursively erase contents of $BLENDERHOME\$SHORTVERSION\scripts? NOTE: This includes all installed scripts and *any* file and directory you have manually created, installed later or copied. This also including .blend files." IDNO NextNoScriptRemove
@ -226,26 +240,27 @@ NextNoConfigRemove:
MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove MessageBox MB_YESNO "Recursively erase contents from $BLENDERHOME\$SHORTVERSION\plugins? NOTE: This includes files and subdirectories in this directory" IDNO NextNoPluginRemove
RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins" RMDir /r "$BLENDERHOME\$SHORTVERSION\plugins"
NextNoPluginRemove: NextNoPluginRemove:
; try to remove dirs, but leave them if they contain anything ; Try to remove dirs, but leave them if they contain anything
RMDir "$BLENDERHOME\$SHORTVERSION\plugins" RMDir "$BLENDERHOME\$SHORTVERSION\plugins"
RMDir "$BLENDERHOME\$SHORTVERSION\config" RMDir "$BLENDERHOME\$SHORTVERSION\config"
RMDir "$BLENDERHOME\$SHORTVERSION\scripts" RMDir "$BLENDERHOME\$SHORTVERSION\scripts"
RMDir "$BLENDERHOME\$SHORTVERSION" RMDir "$BLENDERHOME\$SHORTVERSION"
RMDir "$BLENDERHOME" RMDir "$BLENDERHOME"
; remove shortcuts ; Remove shortcuts
Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*" Delete "$SMPROGRAMS\Blender Foundation\Blender\*.*"
Delete "$DESKTOP\Blender.lnk" Delete "$DESKTOP\Blender.lnk"
; remove all link related directories and files ; Remove all link related directories and files
RMDir "$SMPROGRAMS\Blender Foundation\Blender" RMDir /r "$SMPROGRAMS\Blender Foundation"
RMDir "$SMPROGRAMS\Blender Foundation"
; Clear out installation dir ; Clear out installation dir
RMDir "$INSTDIR" RMDir /r "$INSTDIR"
System::Call 'shell32.dll::SHChangeNotify(i, i, i, i) v (0x08000000, 0, 0, 0)' ; Refresh icons
SectionEnd SectionEnd
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT ${SecCopyUI} $(DESC_SecCopyUI) !insertmacro MUI_DESCRIPTION_TEXT ${InstallFiles} $(DESC_InstallFiles)
!insertmacro MUI_DESCRIPTION_TEXT ${Section2} $(DESC_Section2) !insertmacro MUI_DESCRIPTION_TEXT ${StartMenu} $(DESC_StartMenu)
!insertmacro MUI_DESCRIPTION_TEXT ${Section3} $(DESC_Section3) !insertmacro MUI_DESCRIPTION_TEXT ${DesktopShortcut} $(DESC_DesktopShortcut)
!insertmacro MUI_DESCRIPTION_TEXT ${Section4} $(DESC_Section4) !insertmacro MUI_DESCRIPTION_TEXT ${BlendRegister} $(DESC_BlendRegister)
!insertmacro MUI_FUNCTION_DESCRIPTION_END !insertmacro MUI_FUNCTION_DESCRIPTION_END

@ -127,7 +127,7 @@ typedef struct _DIR {
struct dirent direntry; struct dirent direntry;
} DIR; } DIR;
void RegisterBlendExtension(char * str); void RegisterBlendExtension(void);
DIR *opendir (const char *path); DIR *opendir (const char *path);
struct dirent *readdir(DIR *dp); struct dirent *readdir(DIR *dp);
int closedir (DIR *dp); int closedir (DIR *dp);

@ -43,6 +43,7 @@
#include "BLI_string.h" #include "BLI_string.h"
#include "BKE_utildefines.h" #include "BKE_utildefines.h"
#include "BKE_global.h"
#define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY #define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY
#include "BLI_winstuff.h" #include "BLI_winstuff.h"
@ -64,39 +65,108 @@ int BLI_getInstallationDir( char * str ) {
return 1; return 1;
} }
void RegisterBlendExtension_Fail(HKEY root)
{
printf("failed\n");
if (root)
RegCloseKey(root);
if (!G.background)
MessageBox(0,"Could not register file extension.","Blender error",MB_OK|MB_ICONERROR);
TerminateProcess(GetCurrentProcess(),1);
}
void RegisterBlendExtension(char * str) { void RegisterBlendExtension(void) {
LONG lresult; LONG lresult;
HKEY hkey = 0; HKEY hkey = 0;
HKEY root = 0;
BOOL usr_mode = FALSE;
DWORD dwd = 0; DWORD dwd = 0;
char buffer[128]; char buffer[256];
lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0, char BlPath[MAX_PATH];
"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); char InstallDir[FILE_MAXDIR];
char SysDir[FILE_MAXDIR];
char* ThumbHandlerDLL;
char RegCmd[MAX_PATH*2];
char MBox[256];
BOOL IsWOW64;
if (lresult == ERROR_SUCCESS) { printf("Registering file extension...");
sprintf(buffer, "\"%s\" \"%%1\"", str); GetModuleFileName(0,BlPath,MAX_PATH);
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
RegCloseKey(hkey); // root is HKLM by default
lresult = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
if (lresult != ERROR_SUCCESS)
{
// try HKCU on failure
usr_mode = TRUE;
lresult = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Classes", 0, KEY_ALL_ACCESS, &root);
if (lresult != ERROR_SUCCESS)
RegisterBlendExtension_Fail(0);
} }
lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\DefaultIcon", 0, lresult = RegCreateKeyEx(root, "blendfile", 0,
"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) { if (lresult == ERROR_SUCCESS) {
sprintf(buffer, "\"%s\",1", str); sprintf(buffer,"%s","Blender File");
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1); lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey); RegCloseKey(hkey);
} }
if (lresult != ERROR_SUCCESS)
RegisterBlendExtension_Fail(root);
lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, ".blend", 0, lresult = RegCreateKeyEx(root, "blendfile\\shell\\open\\command", 0,
"", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
sprintf(buffer, "\"%s\" \"%%1\"", BlPath);
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
if (lresult != ERROR_SUCCESS)
RegisterBlendExtension_Fail(root);
lresult = RegCreateKeyEx(root, "blendfile\\DefaultIcon", 0,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
sprintf(buffer, "\"%s\",1", BlPath);
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
if (lresult != ERROR_SUCCESS)
RegisterBlendExtension_Fail(root);
lresult = RegCreateKeyEx(root, ".blend", 0,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) { if (lresult == ERROR_SUCCESS) {
sprintf(buffer, "%s", "blendfile"); sprintf(buffer, "%s", "blendfile");
lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1); lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey); RegCloseKey(hkey);
} }
if (lresult != ERROR_SUCCESS)
RegisterBlendExtension_Fail(root);
BLI_getInstallationDir(InstallDir);
GetSystemDirectory(SysDir,FILE_MAXDIR);
#ifdef WIN64
ThumbHandlerDLL = "BlendThumb64.dll";
#else
IsWow64Process(GetCurrentProcess(),&IsWOW64);
if (IsWOW64 == TRUE)
ThumbHandlerDLL = "BlendThumb64.dll";
else
ThumbHandlerDLL = "BlendThumb.dll";
#endif
snprintf(RegCmd,MAX_PATH*2,"%s\\regsvr32 /s \"%s\\%s\"",SysDir,InstallDir,ThumbHandlerDLL);
system(RegCmd);
RegCloseKey(root);
printf("success (%s)\n",usr_mode ? "user" : "system");
if (!G.background)
{
sprintf(MBox,"File extension registered for %s.",usr_mode ? "the current user. To register for all users, run as an administrator" : "all users");
MessageBox(0,MBox,"Blender",MB_OK|MB_ICONINFORMATION);
}
TerminateProcess(GetCurrentProcess(),0);
} }
DIR *opendir (const char *path) { DIR *opendir (const char *path) {

@ -101,6 +101,17 @@ set(SRC
) )
if(WIN32 AND NOT UNIX) if(WIN32 AND NOT UNIX)
string(SUBSTRING ${BLENDER_VERSION} 0 1 bver1)
string(SUBSTRING ${BLENDER_VERSION} 2 1 bver2)
string(SUBSTRING ${BLENDER_VERSION} 3 1 bver3)
add_definitions(
-DBLEN_VER_RC_STR="${BLENDER_VERSION}"
-DBLEN_VER_RC_1=${bver1}
-DBLEN_VER_RC_2=${bver2}
-DBLEN_VER_RC_3=${bver3}
-DBLEN_VER_RC_4=0
)
list(APPEND SRC list(APPEND SRC
../icons/winblender.rc ../icons/winblender.rc
) )
@ -537,6 +548,19 @@ elseif(WIN32)
endif() endif()
endif() endif()
add_custom_command(TARGET blender
POST_BUILD
MAIN_DEPENDENCY blender
COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb64.dll\" \"${TARGETDIR}\\\"
)
if(NOT CMAKE_CL_64)
add_custom_command(TARGET blender
POST_BUILD
MAIN_DEPENDENCY blender
COMMAND copy /Y \"${LIBDIR}\\thumbhandler\\lib\\BlendThumb.dll\" \"${TARGETDIR}\\\"
)
endif()
elseif(APPLE) elseif(APPLE)
set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app) set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist) set(SOURCEINFO ${SOURCEDIR}/Contents/Info.plist)

@ -287,6 +287,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
#ifdef WIN32 #ifdef WIN32
BLI_argsPrintArgDoc(ba, "-R"); BLI_argsPrintArgDoc(ba, "-R");
BLI_argsPrintArgDoc(ba, "-r");
#endif #endif
BLI_argsPrintArgDoc(ba, "--version"); BLI_argsPrintArgDoc(ba, "--version");
@ -486,12 +487,12 @@ static int without_borders(int UNUSED(argc), const char **UNUSED(argv), void *UN
static int register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data) static int register_extension(int UNUSED(argc), const char **UNUSED(argv), void *data)
{ {
#ifdef WIN32 #ifdef WIN32
char *path = BLI_argsArgv(data)[0]; if (data)
RegisterBlendExtension(path); G.background = 1;
RegisterBlendExtension();
#else #else
(void)data; /* unused */ (void)data; /* unused */
#endif #endif
return 0; return 0;
} }
@ -1094,7 +1095,8 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL); BLI_argsAdd(ba, 2, "-p", "--window-geometry", "<sx> <sy> <w> <h>\n\tOpen with lower left corner at <sx>, <sy> and width and height as <w>, <h>", prefsize, NULL);
BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL); BLI_argsAdd(ba, 2, "-w", "--window-border", "\n\tForce opening with borders (default)", with_borders, NULL);
BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL); BLI_argsAdd(ba, 2, "-W", "--window-borderless", "\n\tForce opening without borders", without_borders, NULL);
BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension (windows only)", register_extension, ba); BLI_argsAdd(ba, 2, "-R", NULL, "\n\tRegister .blend extension, then exit (Windows only)", register_extension, NULL);
BLI_argsAdd(ba, 2, "-r", NULL, "\n\tSilently register .blend extension, then exit (Windows only)", register_extension, ba);
/* third pass: disabling things and forcing settings */ /* third pass: disabling things and forcing settings */
BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle); BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle);

@ -1,9 +1,12 @@
#!/usr/bin/python #!/usr/bin/python
Import ('env') Import ('env')
import btools
if env['OURPLATFORM'] == 'linuxcross': env['RCFLAGS'].append("-DWINDRES")
source = 'linuxcrossblender.rcscons' env['RCFLAGS'].append("-DBLEN_VER_RC_STR_M=" + btools.VERSION)
else: env['RCFLAGS'].append("-DBLEN_VER_RC_1=" + btools.VERSION[0])
source = 'winblender.rcscons' env['RCFLAGS'].append("-DBLEN_VER_RC_2=" + btools.VERSION[2])
env['RCFLAGS'].append("-DBLEN_VER_RC_3=" + btools.VERSION[3])
env['RCFLAGS'].append("-DBLEN_VER_RC_4=0")
env.BlenderRes('winresource', source, ['core'], priority=[95]) env.BlenderRes('winresource', 'winblender.rc', ['core'], priority=[95])

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false"></requestedExecutionLevel>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

@ -1,2 +0,0 @@
APPICON ICON "source/icons/winblender.ico"
BLENDERFILE ICON "source/icons/winblenderfile.ico"

@ -1,2 +1,40 @@
APPICON ICON "winblender.ico" #define BLENDERFILE 1
BLENDERFILE ICON "winblenderfile.ico" #define IDR_VERSION1 1
#ifdef WINDRES
#include "winresrc.h"
#define IDC_STATIC (-1)
#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_(x)
#define BLEN_VER_RC_STR STRINGIFY(BLEN_VER_RC_STR_M)
1 RT_MANIFEST "blender.exe.manifest"
#endif
APPICON ICON DISCARDABLE "winblender.ico"
BLENDERFILE ICON DISCARDABLE "winblenderfile.ico"
IDR_VERSION1 VERSIONINFO
FILEVERSION BLEN_VER_RC_1, BLEN_VER_RC_2, BLEN_VER_RC_3, BLEN_VER_RC_4
PRODUCTVERSION BLEN_VER_RC_1, BLEN_VER_RC_2, BLEN_VER_RC_3, BLEN_VER_RC_4
FILEOS 0x00000004
FILETYPE 0x00000001
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "04090000"
BEGIN
VALUE "FileVersion", BLEN_VER_RC_STR
VALUE "ProductVersion", BLEN_VER_RC_STR
VALUE "CompanyName", "Blender Foundation"
VALUE "FileDescription", "Blender"
VALUE "LegalCopyright", "GPLv2 (Blender Foundation)"
VALUE "OriginalFilename", "blender.exe"
VALUE "ProductName", "Blender"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 0x0000
END
END

@ -1,2 +0,0 @@
APPICON ICON "source\\icons\\winblender.ico"
BLENDERFILE ICON "source\\icons\\winblenderfile.ico"