Use a string table for the dialog message rather than coding it inline.
Also, trim the DisplayName pulled from the registry because Windows 10
seems to prefix it with useless tags.
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
+; // Copyright (c) Citrix Systems Inc.
+; // All rights reserved.
+; //
+; // Redistribution and use in source and binary forms,
+; // with or without modification, are permitted provided
+; // that the following conditions are met:
+; //
+; // * Redistributions of source code must retain the above
+; // copyright notice, this list of conditions and the
+; // following disclaimer.
+; // * Redistributions in binary form must reproduce the above
+; // copyright notice, this list of conditions and the
+; // following disclaimer in the documentation and/or other
+; // materials provided with the distribution.
+; //
+; // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+; // CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+; // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+; // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+; // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+; // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+; // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+; // BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+; // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+; // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+; // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+; // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+; // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+; // SUCH DAMAGE.
+
MessageIdTypedef=DWORD
SeverityNames=(
#include <version.h>
#include "messages.h"
+#include "strings.h"
#define MONITOR_NAME __MODULE__
#define MONITOR_DISPLAYNAME MONITOR_NAME
DWORD MaxValueLength;
DWORD DisplayNameLength;
PTCHAR DisplayName;
+ PTCHAR Description;
DWORD Type;
TCHAR Title[] = TEXT(VENDOR_NAME_STR);
TCHAR Message[MAXIMUM_BUFFER_SIZE];
+ DWORD Length;
PWTS_SESSION_INFO SessionInfo;
DWORD Count;
DWORD Index;
goto fail5;
}
+ Description = _tcsrchr(DisplayName, ';');
+ if (Description == NULL)
+ Description = DisplayName;
+ else
+ Description++;
+
Result = StringCbPrintf(Message,
MAXIMUM_BUFFER_SIZE,
- TEXT("%s needs to restart the system to "
- "complete installation.\n"
- "Press 'Yes' to restart the system "
- "now or 'No' if you plan to restart "
- "the system later.\n"),
- DisplayName);
+ TEXT("%s "),
+ Description);
assert(SUCCEEDED(Result));
+ Length = (DWORD)_tcslen(Message);
+
+ Length = LoadString(GetModuleHandle(NULL),
+ IDS_DIALOG,
+ Message + Length,
+ ARRAYSIZE(Message) - Length);
+ if (Length == 0)
+ goto fail6;
+
Success = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE,
0,
1,
&Count);
if (!Success)
- goto fail6;
+ goto fail7;
for (Index = 0; Index < Count; Index++) {
DWORD SessionId = SessionInfo[Index].SessionId;
TRUE);
if (!Success)
- goto fail7;
+ goto fail8;
Context->RebootPending = TRUE;
return;
-fail7:
- Log("fail7");
+fail8:
+ Log("fail8");
WTSFreeMemory(SessionInfo);
+fail7:
+ Log("fail7");
+
fail6:
Log("fail6");
--- /dev/null
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef _MONITOR_STRINGS_H_
+#define _MONITOR_STRINGS_H_
+
+#define IDS_DIALOG 1
+
+#endif // _MONITOR_STRINGS_H_
--- /dev/null
+/* Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms,
+ * with or without modification, are permitted provided
+ * that the following conditions are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the
+ * following disclaimer in the documentation and/or other
+ * materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "strings.h"
+
+STRINGTABLE
+{
+ IDS_DIALOG, "needs to restart the system to complete installation.\nPress 'Yes' to restart the system now or 'No' if you plan to restart the system later."
+}
\ No newline at end of file
* SUCH DAMAGE.
*/
-
#include <windows.h>
#include <ntverp.h>
#include "common.ver"
#include "messages.rc"
+#include "strings.rc"