OSDN Git Service

Patch [1191248] Merge7zInstaller update
authorJochen Tucht <jtuc@users.sourceforge.net>
Thu, 26 May 2005 16:07:23 +0000 (16:07 +0000)
committerJochen Tucht <jtuc@users.sourceforge.net>
Thu, 26 May 2005 16:07:23 +0000 (16:07 +0000)
ArchiveSupport/Merge7zInstaller/Files.rc2
ArchiveSupport/Merge7zInstaller/Installer.cpp
ArchiveSupport/Merge7zInstaller/Installer.rc
ArchiveSupport/Merge7zInstaller/Merge7zInstaller.dsp

index 0389f34..f9f6341 100755 (executable)
@@ -1,6 +1,6 @@
 #ifndef IMPORT
 #define IMPORT(name) name
-SYSTEMTIME RCDATA {2005,2,0,28,12,0,0,0}
+SYSTEMTIME RCDATA {2005,5,0,26,12,0,0,0}
 #endif
 
 IMPORT(Merge7z311.dll)                 Merge7z "../Build/MergeRelease/Merge7z311.dll"
@@ -27,6 +27,14 @@ IMPORT(Merge7z414.dll)                       Merge7z "../Build/MergeRelease/Merge7z414.dll"
 IMPORT(Merge7z414U.dll)                        Merge7z "../Build/MergeUnicodeRelease/Merge7z414U.dll"
 IMPORT(Merge7z415.dll)                 Merge7z "../Build/MergeRelease/Merge7z415.dll"
 IMPORT(Merge7z415U.dll)                        Merge7z "../Build/MergeUnicodeRelease/Merge7z415U.dll"
+IMPORT(Merge7z416.dll)                 Merge7z "../Build/MergeRelease/Merge7z416.dll"
+IMPORT(Merge7z416U.dll)                        Merge7z "../Build/MergeUnicodeRelease/Merge7z416U.dll"
+IMPORT(Merge7z417.dll)                 Merge7z "../Build/MergeRelease/Merge7z417.dll"
+IMPORT(Merge7z417U.dll)                        Merge7z "../Build/MergeUnicodeRelease/Merge7z417U.dll"
+IMPORT(Merge7z418.dll)                 Merge7z "../Build/MergeRelease/Merge7z418.dll"
+IMPORT(Merge7z418U.dll)                        Merge7z "../Build/MergeUnicodeRelease/Merge7z418U.dll"
+IMPORT(Merge7z419.dll)                 Merge7z "../Build/MergeRelease/Merge7z419.dll"
+IMPORT(Merge7z419U.dll)                        Merge7z "../Build/MergeUnicodeRelease/Merge7z419U.dll"
 
 IMPORT(7zip_pad.xml)                   7-ZIP   "../../../7z313bin/7zip_pad.xml"
 
index 81ca35b..021c1c2 100755 (executable)
@@ -28,6 +28,11 @@ DATE:                BY:                                     DESCRIPTION:
 ==========     ==================      ================================================
 2005/01/15     Jochen Tucht            Created
 2005/02/28     Jochen Tucht            Initialize filename in Open dialog to "*.exe"
+2005/04/26     Jochen Tucht            No default assumption on program directory
+                                                               Double-click option for in-place extraction
+                                                               Fix empty path issue with GetFileTitle()
+                                                               Accept extraction folder on command line
+                                                               Batch options: /standalone, /select, /commit
 */
 
 #include <windows.h>
@@ -45,6 +50,33 @@ static const DWORD dwBuild =
 
 const SYSTEMTIME *st = NULL; // initialized from SYSTEMTIME RCDATA in Files.rc2
 
+LPTSTR NTAPI ArgLower(LPTSTR lpCmdLine)
+{
+       while (*lpCmdLine == VK_SPACE)
+               ++lpCmdLine;
+       return lpCmdLine;
+}
+
+LPTSTR NTAPI ArgUpper(LPTSTR lpCmdLine)
+{
+       TCHAR cSpace = VK_SPACE;
+       while (*lpCmdLine && *lpCmdLine != cSpace)
+       {
+               if (*lpCmdLine == '"')
+               {
+                       cSpace ^= VK_SPACE;
+               }
+               ++lpCmdLine;
+       }
+       return lpCmdLine;
+}
+
+int NTAPI PathGetTailLength(LPCTSTR path)
+{
+       //GetFileTitle() returns garbage when passed in empty path...
+       return *path ? GetFileTitle(path, 0, 0) : 0;
+}
+
 void InstallFile(HWND hWnd, LPTSTR lpName, LPCTSTR lpType, LPTSTR path, int cchPath)
 {
        HMODULE hModule = GetModuleHandle(0);
@@ -72,9 +104,10 @@ void InstallFile(HWND hWnd, LPTSTR lpName, LPCTSTR lpType, LPTSTR path, int cchP
        {
                DWORD dwNumberOfBytesWritten;
                BOOL bSuccess = WriteFile(hFile, pResource, dwSize, &dwNumberOfBytesWritten, 0);
-               FILETIME ft;
-               if (SystemTimeToFileTime(st, &ft))
+               FILETIME ft, ftLocal;
+               if (SystemTimeToFileTime(st, &ftLocal))
                {
+                       LocalFileTimeToFileTime(&ftLocal, &ft);
                        SetFileTime(hFile, &ft, &ft, &ft);
                }
                CloseHandle(hFile);
@@ -118,7 +151,7 @@ BOOL CALLBACK fnInstallFiles(HMODULE hModule, LPCTSTR lpType, LPTSTR lpName, LON
        HWND hWnd = (HWND)lParam;
        TCHAR path[8 * MAX_PATH];
        int cchPath = GetDlgItemText(hWnd, 203, path, 5 * MAX_PATH);
-       int cchName = GetFileTitle(path, 0, 0);
+       int cchName = PathGetTailLength(path);
        if (cchName < cchPath)
        {
                cchPath -= cchName;
@@ -146,8 +179,99 @@ BOOL CALLBACK DlgMain_InitDialog(HWND hWnd, LPARAM lParam)
        LONG lCount = SendDlgItemMessage(hWnd, 100, LB_GETCOUNT , 0, 0);
        SendDlgItemMessage(hWnd, 100, LB_SELITEMRANGEEX, 0, lCount - 1);
        CheckRadioButton(hWnd, 201, 202, 201);
-       GetModuleFileName(0, path, sizeof path);
-       SetDlgItemText(hWnd, 203, path);
+       //GetModuleFileName(0, path, sizeof path);
+       //SetDlgItemText(hWnd, 203, path);
+       BOOL bCommit = FALSE;
+       BOOL bSelect = FALSE;
+       LPTSTR lpCmdLine = GetCommandLine();
+       LPTSTR lpArgLower = ArgLower(lpCmdLine);
+       LPTSTR lpArgUpper = ArgUpper(lpArgLower);
+       while (*(lpArgLower = ArgLower(lpArgUpper)))
+       {
+               TCHAR cAhead = *(lpArgUpper = ArgUpper(lpArgLower));
+               *lpArgUpper = '\0';
+               if (0 == lstrcmpi(lpArgLower, "/standalone"))
+               {
+                       CheckRadioButton(hWnd, 201, 202, 202);
+                       SendMessage(hWnd, WM_COMMAND, 202, 0);
+                       CheckDlgButton(hWnd, 205, 1);
+                       SendMessage(hWnd, WM_COMMAND, 205, 0);
+               }
+               else if (0 == lstrcmpi(lpArgLower, "/select"))
+               {
+                       int lower = -1;
+                       int upper = -1;
+                       *lpArgUpper = cAhead;
+                       if (*(lpArgLower = ArgLower(lpArgUpper)))
+                       {
+                               cAhead = *(lpArgUpper = ArgUpper(lpArgLower));
+                               *lpArgUpper = '\0';
+                               lower = SendDlgItemMessage(hWnd, 100, LB_FINDSTRING, -1, (LPARAM)lpArgLower);
+                               if (lower == -1)
+                               {
+                                       MessageBox(hWnd, lpArgLower, "No match", MB_ICONSTOP);
+                               }
+                       }
+                       *lpArgUpper = cAhead;
+                       if (*(lpArgLower = ArgLower(lpArgUpper)))
+                       {
+                               cAhead = *(lpArgUpper = ArgUpper(lpArgLower));
+                               *lpArgUpper = '\0';
+                               int ahead = -1;
+                               while ((ahead = SendDlgItemMessage(hWnd, 100, LB_FINDSTRING, ahead, (LPARAM)lpArgLower)) > upper)
+                               {
+                                       upper = ahead;
+                               }
+                               if (upper == -1)
+                               {
+                                       MessageBox(hWnd, lpArgLower, "No match", MB_ICONSTOP);
+                               }
+                       }
+                       if (lower >= 0 && upper >= 0)
+                       {
+                               if (!bSelect)
+                               {
+                                       SendDlgItemMessage(hWnd, 100, LB_SETSEL, 0, -1);
+                                       bSelect = TRUE;
+                               }
+                               SendDlgItemMessage(hWnd, 100, LB_SELITEMRANGEEX, lower, upper);
+                       }
+               }
+               else if (0 == lstrcmpi(lpArgLower, "/commit"))
+               {
+                       bCommit = TRUE;
+               }
+               /*//just for test
+               else if (0 == lstrcmpi(lpArgLower, "\"ping pong\""))
+               {
+                       MessageBox(hWnd, "", lpArgLower, 0);
+               }*/
+               else
+               {
+                       DWORD dwAttributes = GetFileAttributes(lpArgLower);
+                       if (dwAttributes != 0xFFFFFFFF && dwAttributes & FILE_ATTRIBUTE_DIRECTORY)
+                       {
+                               lstrcpy(path, lpArgLower);
+                               if (PathGetTailLength(path) > 1)
+                               {
+                                       lstrcat(path, "\\");
+                               }
+                               lstrcat(path, "*.exe");
+                               CheckRadioButton(hWnd, 201, 202, 202);
+                               SendMessage(hWnd, WM_COMMAND, 202, 0);
+                               SetDlgItemText(hWnd, 203, path);
+                       }
+                       else
+                       {
+                               MessageBox(hWnd, lpArgLower, "Not a directory", MB_ICONSTOP);
+                       }
+               }
+               *lpArgUpper = cAhead;
+       }
+       if (bCommit)
+       {
+               SendMessage(hWnd, WM_COMMAND, IDOK, 0);
+       }
        return TRUE;
 }
 
@@ -167,7 +291,7 @@ BOOL CALLBACK DlgMain_BrowseExe(HWND hWnd)
        path.ofn.lpstrTitle = "Browse for application ...";
        path.ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST;
        int cchPath = GetDlgItemText(hWnd, 203, path.buffer, sizeof path.buffer);
-       int cchName = GetFileTitle(path.buffer, 0, 0);
+       int cchName = PathGetTailLength(path.buffer);
        if (cchName < cchPath)
        {
                lstrcpy(path.buffer + cchPath - cchName, "\\*.exe");
@@ -194,7 +318,7 @@ BOOL CALLBACK DlgMain_InstallFiles(HWND hWnd)
        else
        {
                cchPath = GetDlgItemText(hWnd, 203, path, 5 * MAX_PATH);
-               int cchName = GetFileTitle(path, 0, 0);
+               int cchName = PathGetTailLength(path);
                if (cchName < cchPath)
                {
                        cchPath -= cchName;
@@ -235,6 +359,7 @@ BOOL CALLBACK DlgMain_EnableStandalone(HWND hWnd)
 
 BOOL CALLBACK DlgMain(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 {
+       TCHAR path[8 * MAX_PATH];
        switch (uMsg)
        {
        case WM_INITDIALOG:
@@ -249,11 +374,19 @@ BOOL CALLBACK DlgMain(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
                        EnableWindow(GetDlgItem(hWnd, 203), wParam == 202);
                        EnableWindow(GetDlgItem(hWnd, 204), wParam == 202);
                        EnableWindow(GetDlgItem(hWnd, 205), wParam == 202);
+                       SetDlgItemText(hWnd, 203, "");
+                       break;
+               case MAKELONG(202, BN_DOUBLECLICKED):
+                       GetModuleFileName(0, path, sizeof path);
+                       SetDlgItemText(hWnd, 203, path);
+                       break;
+               case MAKELONG(203, EN_CHANGE):
+                       EnableWindow(GetDlgItem(hWnd, IDOK), GetWindowTextLength((HWND)lParam) || IsDlgButtonChecked(hWnd, 201));
                        break;
                case 204:
                        return DlgMain_BrowseExe(hWnd);
                case 205:
-                       if (IsDlgButtonChecked(hWnd, 205))
+                       if (IsDlgButtonChecked(hWnd, 205) && GetKeyState(VK_SHIFT) >= 0)
                                SendDlgItemMessage(hWnd, 100, LB_SETSEL, 0, -1);
                        //fall through
                case MAKELONG(100, LBN_SELCHANGE):
index 5499f54..1682edd 100755 (executable)
@@ -49,30 +49,30 @@ END
 // Dialog
 //
 
-100 DIALOGEX 0, 0, 308, 177
+100 DIALOGEX 0, 0, 308, 185
 STYLE DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION | 
     WS_SYSMENU
 CAPTION "Merge7z Interface Plugin Installer"
 FONT 8, "MS Sans Serif"
 BEGIN
-    GROUPBOX        "&Select plugins to be installed",IDC_STATIC,2,0,304,82,
+    GROUPBOX        "&Select plugins to be installed",IDC_STATIC,2,0,304,90,
                     WS_GROUP,WS_EX_TRANSPARENT
-    LISTBOX         100,6,10,296,68,LBS_NOINTEGRALHEIGHT | LBS_MULTICOLUMN | 
-                    LBS_EXTENDEDSEL | WS_VSCROLL | WS_GROUP | WS_TABSTOP
-    GROUPBOX        "&Options",IDC_STATIC,2,84,304,72,WS_GROUP,
+    LISTBOX         100,6,10,296,76,LBS_NOINTEGRALHEIGHT | LBS_MULTICOLUMN | 
+                    LBS_EXTENDEDSEL | WS_HSCROLL | WS_GROUP | WS_TABSTOP
+    GROUPBOX        "&Options",IDC_STATIC,2,92,304,72,WS_GROUP,
                     WS_EX_TRANSPARENT
-    CONTROL         "Install to s&ystem directory",201,"Button",
-                    BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,6,94,94,10
-    CONTROL         "Install to &program directory",202,"Button",
-                    BS_AUTORADIOBUTTON | WS_TABSTOP,6,106,98,10
-    EDITTEXT        203,18,118,232,14,ES_AUTOHSCROLL | WS_DISABLED | 
+    CONTROL         "S&hared installation",201,"Button",BS_AUTORADIOBUTTON | 
+                    WS_GROUP | WS_TABSTOP,6,102,73,10
+    CONTROL         "&Application specific installation",202,"Button",
+                    BS_AUTORADIOBUTTON | BS_NOTIFY | WS_TABSTOP,6,114,111,10
+    EDITTEXT        203,18,126,232,14,ES_AUTOHSCROLL | WS_DISABLED | 
                     WS_GROUP
-    PUSHBUTTON      "&Browse",204,252,118,50,14,WS_DISABLED | WS_GROUP
+    PUSHBUTTON      "&Browse",204,252,126,50,14,WS_DISABLED | WS_GROUP
     CONTROL         "&Enable standalone operation\nThis option adds required components from 7-Zip 3.13 to program directory.",
                     205,"Button",BS_AUTOCHECKBOX | BS_TOP | BS_MULTILINE | 
-                    WS_DISABLED | WS_TABSTOP,18,134,280,18
-    DEFPUSHBUTTON   "OK",IDOK,202,160,50,14,WS_GROUP
-    PUSHBUTTON      "Cancel",IDCANCEL,256,160,50,14,WS_GROUP
+                    WS_DISABLED | WS_TABSTOP,18,142,280,18
+    DEFPUSHBUTTON   "OK",IDOK,202,168,50,14,WS_GROUP
+    PUSHBUTTON      "Cancel",IDCANCEL,256,168,50,14,WS_GROUP
 END
 
 
@@ -89,7 +89,7 @@ BEGIN
         LEFTMARGIN, 7
         RIGHTMARGIN, 301
         TOPMARGIN, 7
-        BOTTOMMARGIN, 170
+        BOTTOMMARGIN, 178
     END
 END
 #endif    // APSTUDIO_INVOKED
index 49d2f6f..d415f56 100755 (executable)
@@ -55,11 +55,29 @@ BSC32=bscmake.exe
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /pdb:none /machine:I386 /nodefaultlib
-# Begin Special Build Tool
+# Begin Custom Build
+OutDir=.\Release
+InputPath=.\Release\Merge7zInstaller.exe
 SOURCE="$(InputPath)"
-PostBuild_Desc=UPX compression
-PostBuild_Cmds=upx Release/Merge7zInstaller.exe
-# End Special Build Tool
+
+BuildCmds= \
+       upx $(OUTDIR)\Merge7zInstaller.exe \
+       cd $(OUTDIR) \
+       del Merge7z.7z \
+       del Merge7z.zip \
+       mkdir Zip \
+       Merge7zInstaller /commit /standalone /select M M Zip \
+       cd Zip \
+       7za a ..\Merge7z.7z -r * -mx5 \
+       7za a -tzip ..\Merge7z.zip -r * -mx5 \
+       
+
+"$(OUTDIR)\Merge7z.7z" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+   $(BuildCmds)
+
+"$(OUTDIR)\Merge7z.zip" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+   $(BuildCmds)
+# End Custom Build
 
 !ELSEIF  "$(CFG)" == "Merge7zInstaller - Win32 Debug"
 
@@ -86,6 +104,20 @@ BSC32=bscmake.exe
 LINK32=link.exe
 # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /nodefaultlib /pdbtype:sept
+# Begin Custom Build
+OutDir=.\Debug
+InputPath=.\Debug\Merge7zInstaller.exe
+SOURCE="$(InputPath)"
+
+"$(OUTDIR)\Merge7z.7z" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
+       cd $(OUTDIR) 
+       del Merge7z.7z 
+       mkdir Zip 
+       Merge7zInstaller /commit /standalone /select M M Zip 
+       cd Zip 
+       7za a ..\Merge7z.7z -r * 
+       
+# End Custom Build
 
 !ENDIF