Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorNathan Letwory <nathan@letworyinteractive.com>2011-03-29 17:00:03 +0400
committerNathan Letwory <nathan@letworyinteractive.com>2011-03-29 17:00:03 +0400
commite4e78d475457ad86f5f29a0ccbd0090c2ba6b1d6 (patch)
treef83fbddff846b39862f2d6bc2af4020bd6821009 /source
parent74e044065b35e5444871f8f5836b221144588082 (diff)
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!
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenlib/BLI_winstuff.h2
-rw-r--r--source/blender/blenlib/intern/winstuff.c100
-rw-r--r--source/creator/CMakeLists.txt24
-rw-r--r--source/creator/creator.c10
-rw-r--r--source/icons/SConscript13
-rw-r--r--source/icons/blender.exe.manifest10
-rw-r--r--source/icons/linuxcrossblender.rcscons2
-rw-r--r--source/icons/winblender.rc42
-rw-r--r--source/icons/winblender.rcscons2
9 files changed, 174 insertions, 31 deletions
diff --git a/source/blender/blenlib/BLI_winstuff.h b/source/blender/blenlib/BLI_winstuff.h
index 957e5fd0b78..d0eb3c7d67d 100644
--- a/source/blender/blenlib/BLI_winstuff.h
+++ b/source/blender/blenlib/BLI_winstuff.h
@@ -127,7 +127,7 @@ typedef struct _DIR {
struct dirent direntry;
} DIR;
-void RegisterBlendExtension(char * str);
+void RegisterBlendExtension(void);
DIR *opendir (const char *path);
struct dirent *readdir(DIR *dp);
int closedir (DIR *dp);
diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c
index a6dae7958cc..2f750545223 100644
--- a/source/blender/blenlib/intern/winstuff.c
+++ b/source/blender/blenlib/intern/winstuff.c
@@ -43,6 +43,7 @@
#include "BLI_string.h"
#include "BKE_utildefines.h"
+#include "BKE_global.h"
#define WIN32_SKIP_HKEY_PROTECTION // need to use HKEY
#include "BLI_winstuff.h"
@@ -64,39 +65,108 @@ int BLI_getInstallationDir( char * str ) {
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;
HKEY hkey = 0;
+ HKEY root = 0;
+ BOOL usr_mode = FALSE;
DWORD dwd = 0;
- char buffer[128];
-
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\shell\\open\\command", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ char buffer[256];
+
+ char BlPath[MAX_PATH];
+ char InstallDir[FILE_MAXDIR];
+ char SysDir[FILE_MAXDIR];
+ char* ThumbHandlerDLL;
+ char RegCmd[MAX_PATH*2];
+ char MBox[256];
+ BOOL IsWOW64;
+ printf("Registering file extension...");
+ GetModuleFileName(0,BlPath,MAX_PATH);
+
+ // 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(root, "blendfile", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
- sprintf(buffer, "\"%s\" \"%%1\"", str);
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ sprintf(buffer,"%s","Blender File");
+ lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey);
}
+ if (lresult != ERROR_SUCCESS)
+ RegisterBlendExtension_Fail(root);
- lresult = RegCreateKeyEx(HKEY_CLASSES_ROOT, "blendfile\\DefaultIcon", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
-
+ lresult = RegCreateKeyEx(root, "blendfile\\shell\\open\\command", 0,
+ NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) {
- sprintf(buffer, "\"%s\",1", str);
- lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, buffer, strlen(buffer) + 1);
+ 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(HKEY_CLASSES_ROOT, ".blend", 0,
- "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
+ 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) {
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);
}
+ 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) {
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 99c7dba9305..b25cac7bf78 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -101,6 +101,17 @@ set(SRC
)
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
../icons/winblender.rc
)
@@ -536,6 +547,19 @@ elseif(WIN32)
)
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)
set(SOURCEDIR ${CMAKE_SOURCE_DIR}/source/darwin/blender.app)
diff --git a/source/creator/creator.c b/source/creator/creator.c
index 2480f8b544b..1db143cdd20 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -287,6 +287,7 @@ static int print_help(int UNUSED(argc), const char **UNUSED(argv), void *data)
#ifdef WIN32
BLI_argsPrintArgDoc(ba, "-R");
+ BLI_argsPrintArgDoc(ba, "-r");
#endif
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)
{
#ifdef WIN32
- char *path = BLI_argsArgv(data)[0];
- RegisterBlendExtension(path);
+ if (data)
+ G.background = 1;
+ RegisterBlendExtension();
#else
(void)data; /* unused */
#endif
-
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, "-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, "-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 */
BLI_argsAddCase(ba, 3, "-nojoystick", 1, NULL, 0, "\n\tDisable joystick support", no_joystick, syshandle);
diff --git a/source/icons/SConscript b/source/icons/SConscript
index ca6308781e9..4bb27a7d4fb 100644
--- a/source/icons/SConscript
+++ b/source/icons/SConscript
@@ -1,9 +1,12 @@
#!/usr/bin/python
Import ('env')
+import btools
-if env['OURPLATFORM'] == 'linuxcross':
- source = 'linuxcrossblender.rcscons'
-else:
- source = 'winblender.rcscons'
+env['RCFLAGS'].append("-DWINDRES")
+env['RCFLAGS'].append("-DBLEN_VER_RC_STR_M=" + btools.VERSION)
+env['RCFLAGS'].append("-DBLEN_VER_RC_1=" + btools.VERSION[0])
+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])
diff --git a/source/icons/blender.exe.manifest b/source/icons/blender.exe.manifest
new file mode 100644
index 00000000000..bc13bf4c586
--- /dev/null
+++ b/source/icons/blender.exe.manifest
@@ -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>
diff --git a/source/icons/linuxcrossblender.rcscons b/source/icons/linuxcrossblender.rcscons
deleted file mode 100644
index cf3083aa472..00000000000
--- a/source/icons/linuxcrossblender.rcscons
+++ /dev/null
@@ -1,2 +0,0 @@
-APPICON ICON "source/icons/winblender.ico"
-BLENDERFILE ICON "source/icons/winblenderfile.ico"
diff --git a/source/icons/winblender.rc b/source/icons/winblender.rc
index 77e62111d2d..244c2cb2e2c 100644
--- a/source/icons/winblender.rc
+++ b/source/icons/winblender.rc
@@ -1,2 +1,40 @@
-APPICON ICON "winblender.ico"
-BLENDERFILE ICON "winblenderfile.ico"
+#define BLENDERFILE 1
+#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
+
diff --git a/source/icons/winblender.rcscons b/source/icons/winblender.rcscons
deleted file mode 100644
index 97579f1ffe0..00000000000
--- a/source/icons/winblender.rcscons
+++ /dev/null
@@ -1,2 +0,0 @@
-APPICON ICON "source\\icons\\winblender.ico"
-BLENDERFILE ICON "source\\icons\\winblenderfile.ico"