src/jdk.jpackage/windows/native/libjpackage/WinSysInfo.cpp
branchJDK-8200758-branch
changeset 57444 91e9d4691e5e
parent 57413 45c74e654794
child 57909 c7de06ed4b54
--- a/src/jdk.jpackage/windows/native/libjpackage/WinSysInfo.cpp	Fri Jun 28 16:49:32 2019 -0400
+++ b/src/jdk.jpackage/windows/native/libjpackage/WinSysInfo.cpp	Fri Jun 28 16:50:51 2019 -0400
@@ -23,10 +23,15 @@
  * questions.
  */
 
+#include <windows.h>
+#include <shellapi.h>
+
 #include "WinSysInfo.h"
 #include "FileUtils.h"
 #include "WinErrorHandling.h"
 
+#pragma comment(lib, "Shell32")
+
 namespace SysInfo {
 
 tstring getTempDir() {
@@ -113,6 +118,24 @@
     return getModulePath(getCurrentModuleHandle());
 }
 
+tstring_array getCommandArgs(CommandArgProgramNameMode progNameMode)
+{
+    int argc = 0;
+    tstring_array result;
+
+    LPWSTR *parsedArgs = CommandLineToArgvW(GetCommandLineW(), &argc);
+    if (parsedArgs == NULL) {
+        JP_THROW(SysError("CommandLineToArgvW failed", CommandLineToArgvW));
+    }
+    // the 1st element contains program name
+    for (int i = progNameMode == ExcludeProgramName ? 1 : 0; i < argc; i++) {
+        result.push_back(parsedArgs[i]);
+    }
+    LocalFree(parsedArgs);
+
+    return result;
+}
+
 namespace {
 
 tstring getEnvVariableImpl(const tstring& name, bool* errorOccured=0) {