[NET] Load netmsg.dll right from the start and print some messages using netmsg.dll rather than local strings.

@Translators: Please start translating messages from netmsgmsg.mc and errorcodes.mc (located in sdk\include\reactos\mc). They will be used instead of local strings.
This commit is contained in:
Eric Kohl 2018-12-23 14:16:53 +01:00
parent 2955ed91ab
commit d5c74ae6fe
8 changed files with 38 additions and 42 deletions

View file

@ -302,7 +302,7 @@ done:
NetApiBufferFree(ServerInfo);
if (result == 0)
ConResPuts(StdOut, IDS_ERROR_NO_ERROR);
PrintErrorMessage(ERROR_SUCCESS);
return result;
}

View file

@ -255,6 +255,7 @@ cmdGroup(
}
else
{
PrintErrorMessage(3506/*, argv[i]*/);
result = 1;
goto done;
}

View file

@ -13,8 +13,6 @@
INT cmdHelpMsg(INT argc, WCHAR **argv)
{
WCHAR szBuffer[MAX_PATH];
HMODULE hMsgDll = NULL;
INT i;
LONG errNum;
PWSTR endptr;
@ -52,20 +50,9 @@ INT cmdHelpMsg(INT argc, WCHAR **argv)
if (errNum >= MIN_LANMAN_MESSAGE_ID && errNum <= MAX_LANMAN_MESSAGE_ID)
{
/* Load netmsg.dll */
GetSystemDirectoryW(szBuffer, ARRAYSIZE(szBuffer));
wcscat(szBuffer, L"\\netmsg.dll");
hMsgDll = LoadLibrary(szBuffer);
if (hMsgDll == NULL)
{
ConPrintf(StdOut, L"Failed to load netmsg.dll\n");
return 0;
}
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_ARGUMENT_ARRAY,
hMsgDll,
hModuleNetMsg,
errNum,
LANG_USER_DEFAULT,
(LPWSTR)&pBuffer,
@ -80,8 +67,6 @@ INT cmdHelpMsg(INT argc, WCHAR **argv)
{
PrintErrorMessage(3871);
}
FreeLibrary(hMsgDll);
}
else
{

View file

@ -275,6 +275,7 @@ cmdLocalGroup(
}
else
{
PrintErrorMessage(3506/*, argv[i]*/);
result = 1;
goto done;
}

View file

@ -294,7 +294,7 @@ cmdStatistics(
}
if (result == 0)
ConResPuts(StdOut, IDS_ERROR_NO_ERROR);
PrintErrorMessage(ERROR_SUCCESS);
return result;
}

View file

@ -109,7 +109,7 @@ cmdUse(
{
Status = EnumerateConnections(NULL);
if (Status == NO_ERROR)
ConResPrintf(StdOut, IDS_ERROR_NO_ERROR);
PrintErrorMessage(ERROR_SUCCESS);
else
PrintError(Status);
@ -125,7 +125,7 @@ cmdUse(
Status = EnumerateConnections(argv[2]);
if (Status == NO_ERROR)
ConResPrintf(StdOut, IDS_ERROR_NO_ERROR);
PrintErrorMessage(ERROR_SUCCESS);
else
PrintError(Status);

View file

@ -45,6 +45,7 @@ COMMAND cmds[] =
{NULL, NULL}
};
HMODULE hModuleNetMsg = NULL;
VOID
@ -80,28 +81,15 @@ VOID
PrintErrorMessage(
DWORD dwError)
{
WCHAR szDllBuffer[MAX_PATH];
WCHAR szErrorBuffer[16];
HMODULE hMsgDll = NULL;
PWSTR pBuffer;
PWSTR pErrorInserts[2] = {NULL, NULL};
/* Load netmsg.dll */
GetSystemDirectoryW(szDllBuffer, ARRAYSIZE(szDllBuffer));
wcscat(szDllBuffer, L"\\netmsg.dll");
hMsgDll = LoadLibrary(szDllBuffer);
if (hMsgDll == NULL)
{
ConPrintf(StdErr, L"Failed to load netmsg.dll\n");
return;
}
if (dwError >= MIN_LANMAN_MESSAGE_ID && dwError <= MAX_LANMAN_MESSAGE_ID)
{
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_IGNORE_INSERTS,
hMsgDll,
hModuleNetMsg,
dwError,
LANG_USER_DEFAULT,
(LPWSTR)&pBuffer,
@ -141,7 +129,7 @@ PrintErrorMessage(
/* Format and print the 3514 message */
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE |
FORMAT_MESSAGE_ARGUMENT_ARRAY,
hMsgDll,
hModuleNetMsg,
3514,
LANG_USER_DEFAULT,
(LPWSTR)&pBuffer,
@ -154,8 +142,6 @@ PrintErrorMessage(
pBuffer = NULL;
}
}
FreeLibrary(hMsgDll);
}
@ -198,15 +184,29 @@ ReadFromConsole(
int wmain(int argc, WCHAR **argv)
{
WCHAR szDllBuffer[MAX_PATH];
PCOMMAND cmdptr;
int nResult = 0;
BOOL bRun = FALSE;
/* Initialize the Console Standard Streams */
ConInitStdStreams();
/* Load netmsg.dll */
GetSystemDirectoryW(szDllBuffer, ARRAYSIZE(szDllBuffer));
wcscat(szDllBuffer, L"\\netmsg.dll");
hModuleNetMsg = LoadLibrary(szDllBuffer);
if (hModuleNetMsg == NULL)
{
ConPrintf(StdErr, L"Failed to load netmsg.dll\n");
return 1;
}
if (argc < 2)
{
ConResPuts(StdOut, IDS_NET_SYNTAX);
return 1;
nResult = 1;
goto done;
}
/* Scan the command table */
@ -214,13 +214,20 @@ int wmain(int argc, WCHAR **argv)
{
if (_wcsicmp(argv[1], cmdptr->name) == 0)
{
return cmdptr->func(argc, argv);
nResult = cmdptr->func(argc, argv);
bRun = TRUE;
break;
}
}
ConResPuts(StdOut, IDS_NET_SYNTAX);
done:
if (bRun == FALSE)
ConResPuts(StdOut, IDS_NET_SYNTAX);
return 1;
if (hModuleNetMsg != NULL)
FreeLibrary(hModuleNetMsg);
return nResult;
}
INT unimplemented(INT argc, WCHAR **argv)

View file

@ -26,6 +26,8 @@
#include "resource.h"
extern HMODULE hModuleNetMsg;
VOID
PrintPaddedResourceString(
UINT uID,