Allow regsvr32 to register multiple DLLs at once

Mike Hearn mike at theoretic.com
Mon Dec 15 17:38:53 CST 2003


When you just get the urge to reregister your entire windows/system
directory...

Mike Hearn <mike at theoretic.com>
Allow regsvr32 to register multiple DLLs even if some fail

Index: programs/regsvr32/regsvr32.c
===================================================================
RCS file: /home/wine/wine/programs/regsvr32/regsvr32.c,v
retrieving revision 1.7
diff -u -r1.7 regsvr32.c
--- programs/regsvr32/regsvr32.c        7 Oct 2003 22:49:44 -0000       1.7
+++ programs/regsvr32/regsvr32.c        15 Dec 2003 23:34:16 -0000
@@ -31,6 +31,7 @@
  *  [/i]    Call DllInstall passing it an optional [cmdline];
  *          when used with /u calls dll uninstall.
  *  [/n]    Do not call DllRegisterServer; this option must be used with [/i]
+ *  [/h]    Do not stop on first error (wine specific)
  *
  *  Note the complication that this version may be passed unix format file names
  *  which might be mistaken for flags.  Conveniently the Windows version
@@ -57,6 +58,7 @@
 typedef HRESULT (*DLLINSTALL)           (BOOL,LPCWSTR);
  
 int Silent = 0;
+int StopOnFirstError = 1;
  
 int Usage()
 {
@@ -67,6 +69,7 @@
     printf("\t      when used with /u calls dll uninstall\n");
     printf("\t[/n]  Do not call DllRegisterServer; this option "
            "must be used with [/i]\n");
+    printf("\t[/h]  Do not halt on first error\n");
     return 0;
 }
  
@@ -88,7 +91,7 @@
         if(!Silent)
             printf("Dll %s not found\n", strDll);
  
-        exit(-1);
+        return NULL;
     }
     proc = (VOID *) GetProcAddress(*DllHandle, procName);
     if(!proc)
@@ -96,7 +99,7 @@
         if(!Silent)
             printf("%s not implemented in dll %s\n", procName, strDll);
         FreeLibrary(*DllHandle);
-        exit(-1);
+        return NULL;
     }
     return proc;
 }
@@ -108,6 +111,7 @@
     HMODULE DllHandle = NULL;
  
     pfRegister = LoadProc(strDll, "DllRegisterServer", &DllHandle);
+    if (!pfRegister) return -1;
  
     hr = pfRegister();
     if(FAILED(hr))
@@ -132,6 +136,8 @@
     HMODULE DllHandle = NULL;
  
     pfUnregister = LoadProc(strDll, "DllUnregisterServer", &DllHandle);
+    if (!pfUnregister) return -1;
+
     hr = pfUnregister();
     if(FAILED(hr))
     {
@@ -155,6 +161,8 @@
     HMODULE DllHandle = NULL;
  
     pfInstall = LoadProc(strDll, "DllInstall", &DllHandle);
+    if (!pfInstall) return -1;
+
     hr = pfInstall(install, command_line);
     if(FAILED(hr))
     {
@@ -194,6 +202,8 @@
                 Unregister = TRUE;
         else if (!strcasecmp(argv[i], "/s"))
                 Silent = 1;
+       else if (!strcasecmp(argv[i], "/h"))
+               StopOnFirstError = 0;
         else if (!strncasecmp(argv[i], "/i", strlen("/i")))
         {
             CHAR* command_line = argv[i] + strlen("/i");
@@ -254,7 +264,7 @@
                     res = RegisterDll(DllName);
             }
  
-            if (res)
+            if (res && StopOnFirstError)
                 return res;
            /* Confirmed.  The windows version does stop on the first error.*/
  
@@ -263,7 +273,7 @@
                 res = InstallDll(!Unregister, DllName, wsCommandLine);
             }
  
-            if (res)
+            if (res && StopOnFirstError)
                return res;
         }
     }





More information about the wine-patches mailing list