[TRANSLATION][CLIPBRD] Italian translation implemented (#344)
[reactos.git] / base / system / regsvr32 / regsvr32.c
index c3e4d86..ae64e53 100644 (file)
@@ -9,8 +9,6 @@
  * PROGRAMMER:      ShadowFlare (blakflare@hotmail.com)
  */
 
-#define WIN32_LEAN_AND_MEAN
-
 // Both UNICODE and _UNICODE must be either defined or undefined
 // because some headers use UNICODE and others use _UNICODE
 #ifdef UNICODE
 #endif
 #endif
 
-#include <windows.h>
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
 #include <ole2.h>
-#include <stdio.h>
-#include <string.h>
-#include <malloc.h>
 #include <tchar.h>
 
 typedef HRESULT (WINAPI *DLLREGISTER)(void);
@@ -52,8 +52,6 @@ LPCWSTR tszDllInstall = L"DllInstall";
 #define tszDllInstall szDllInstall
 #endif
 
-
-
 #include "resource.h"
 
 LPCTSTR ModuleTitle = _T("RegSvr32");
@@ -67,7 +65,6 @@ TCHAR MissingEntry[RC_STRING_MAX_SIZE];
 TCHAR FailureMessage[RC_STRING_MAX_SIZE];
 TCHAR SuccessMessage[RC_STRING_MAX_SIZE];
 
-
 // The macro CommandLineToArgv maps to a function that converts
 // a command-line string to argc and argv similar to the ones
 // in the standard main function.  If this code is compiled for
@@ -214,7 +211,7 @@ LPTSTR *WINAPI CommandLineToArgvT(LPCTSTR lpCmdLine, int *lpArgc)
 
 // The macro ConvertToWideChar takes a tstring parameter and returns
 // a pointer to a unicode string.  A conversion is performed if
-// neccessary.  FreeConvertedWideChar string should be used on the
+// necessary.  FreeConvertedWideChar string should be used on the
 // return value of ConvertToWideChar when the string is no longer
 // needed.  The original string or the string that is returned
 // should not be modified until FreeConvertedWideChar has been called.
@@ -261,7 +258,7 @@ int WINAPI _tWinMain(
        LPCSTR lpFuncName;
        LPWSTR lpwDllCmdLine;
        BOOL bUnregister,bSilent,bConsole,bInstall,bNoRegister;
-       UINT nDllCount;
+       UINT nDllCount, fuOldErrorMode;
        HMODULE hDll;
        DLLREGISTER fnDllRegister;
        DLLINSTALL fnDllInstall;
@@ -295,7 +292,7 @@ int WINAPI _tWinMain(
 
        // Find all arguments starting with a slash (/)
        for (i = 1; i < argc; i++) {
-               if (*argv[i] == _T('/')) {
+               if (*argv[i] == _T('/') || *argv[i] == '-') {
                        switch (argv[i][1]) {
                        case _T('u'):
                        case _T('U'):
@@ -389,9 +386,11 @@ int WINAPI _tWinMain(
                if (*argv[i] != _T('/')) {
                        lptDllName = argv[i];
 
+                       fuOldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
                        // Everything is all setup, so load the dll now
                        hDll = LoadLibraryEx(lptDllName,0,LOAD_WITH_ALTERED_SEARCH_PATH);
                        if (hDll) {
+                               SetErrorMode(fuOldErrorMode);
                                if (!bNoRegister) {
                                        // Get the address of DllRegisterServer or DllUnregisterServer
                                        fnDllRegister = (DLLREGISTER)GetProcAddress(hDll,lpFuncName);
@@ -451,7 +450,6 @@ int WINAPI _tWinMain(
                                                        nRetValue = EXITCODE_FAILURE;
                                        }
                                        else {
-                                               FreeLibrary(hDll);
                                                // DllInstall was not found, display an error message
                                                lptMsgBuffer = (LPTSTR)malloc((_tcslen(MissingEntry) - 8 + _tcslen(tszDllInstall) * 2 + _tcslen(lptDllName) * 2 + 1) * sizeof(TCHAR));
                                                _stprintf(lptMsgBuffer,MissingEntry,lptDllName,tszDllInstall,tszDllInstall,lptDllName);
@@ -467,6 +465,7 @@ int WINAPI _tWinMain(
                        else {
                                // The dll could not be loaded; display an error message
                                dwErr = GetLastError();
+                               SetErrorMode(fuOldErrorMode);
                                lptMsgBuffer = (LPTSTR)malloc((_tcslen(DllNotLoaded) + 2 + _tcslen(lptDllName) + 1) * sizeof(TCHAR));
                                _stprintf(lptMsgBuffer,DllNotLoaded,lptDllName,dwErr);
                                DisplayMessage(bConsole,bSilent,lptMsgBuffer,ModuleTitle,MB_ICONEXCLAMATION);
@@ -482,4 +481,3 @@ int WINAPI _tWinMain(
        OleUninitialize();
        return nRetValue;
 }
-