summaryrefslogtreecommitdiff
path: root/win/win32service.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'win/win32service.cpp')
-rw-r--r--win/win32service.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/win/win32service.cpp b/win/win32service.cpp
index 81f8e7516..b04eff558 100644
--- a/win/win32service.cpp
+++ b/win/win32service.cpp
@@ -55,7 +55,9 @@ SETSERVDESC ChangeServiceConf;
LPCSTR RetrieveLastError()
{
static char err[100];
- FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)err, sizeof(err), 0);
+ DWORD LastError = GetLastError();
+ if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS, 0, LastError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)err, sizeof(err), 0) == 0)
+ snprintf(err, sizeof(err), "Error code: %d", LastError);
SetLastError(ERROR_SUCCESS);
return err;
}