diff --git a/BSCP/ConfigurableShell/ConfigurableShell.cpp b/BSCP/ConfigurableShell/ConfigurableShell.cpp index 686ec2e..5a1519d 100644 --- a/BSCP/ConfigurableShell/ConfigurableShell.cpp +++ b/BSCP/ConfigurableShell/ConfigurableShell.cpp @@ -116,10 +116,23 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) DWORD cbXming = 0; DWORD ccXming = 0; WCHAR* xming_val = prov.pwszGetValueAt_sz(s_RegistryKey_Shell, TEXT("xming"), &cbXming, &ccXming); + //load xming full command + DWORD cbXmingCommand = 0; + DWORD ccXmingCommand = 0; + WCHAR* xming_command_val = prov.pwszGetValueAt_sz(s_RegistryKey_Shell, TEXT("xming_command"), &cbXmingCommand, &ccXmingCommand); //execute shell command if (_wcsicmp(xming_val, TEXT("true")) == 0) { - char* x = "\"C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl"; //first try with optimized Xming - result = WinExec(x, SW_SHOW); + // TODO - does this work? + if (wcslen(xming_command_val) == 0) { + char* x = "\"C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl"; //first try with optimized Xming + result = WinExec(x, SW_SHOW); + } + else { + char* convertedString = new char [ccXmingCommand]; + wcstombs(convertedString, xming_command_val, wcslen(xming_command_val)); + result = WinExec(convertedString, SW_SHOW); + } + if (result <= 31) { //Error state, try again char* y = "\"C:\\Program Files (x86)\\Xming\\Xming.exe\" :0 -clipboard -fullscreen"; result = WinExec(y, SW_SHOW); diff --git a/BSCP/ConfigurableShell/ConfigurableShell.vcxproj b/BSCP/ConfigurableShell/ConfigurableShell.vcxproj index 0d87001..ba7e279 100644 --- a/BSCP/ConfigurableShell/ConfigurableShell.vcxproj +++ b/BSCP/ConfigurableShell/ConfigurableShell.vcxproj @@ -87,7 +87,7 @@ Use Level3 Disabled - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_WINDOWS;%(PreprocessorDefinitions) true @@ -115,7 +115,7 @@ MaxSpeed true true - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) true diff --git a/BSCP/Configurator/ConfigModel.cs b/BSCP/Configurator/ConfigModel.cs index 99083fd..9cb30f7 100644 --- a/BSCP/Configurator/ConfigModel.cs +++ b/BSCP/Configurator/ConfigModel.cs @@ -23,6 +23,7 @@ protected void OnPropertyChanged(string name) private String _name; private String _command; private String _console; + private string _xmingCommand; private Boolean _usesXming; public String Name { @@ -69,6 +70,18 @@ public String Console } } } + public string XmingCommand + { + get => _xmingCommand; + set + { + if (value != _xmingCommand) + { + _xmingCommand = value; + OnPropertyChanged(nameof(XmingCommand)); + } + } + } public String DefaultCommand { get; set; } public String DefaultConsole { get; set; } @@ -76,12 +89,13 @@ public ConfigModel() { } - public ConfigModel(String name, String defaultCommand, String defaultConsole, Boolean uses_xming = true) + public ConfigModel(String name, String defaultCommand, String defaultConsole, Boolean uses_xming = true, String defaultXmingString = "C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl") { this.Name = name; this.DefaultCommand = defaultCommand; this.DefaultConsole = defaultConsole; this._usesXming = uses_xming; + this._xmingCommand = defaultXmingString; } /// @@ -93,6 +107,15 @@ public void readOrUpdateFromRegistry() var console_key = Registry.GetValue(get_full_name(), "console", null); var xming_key = Registry.GetValue(get_full_name(), "xming", null); var name_key = Registry.GetValue(get_full_name(), "name", null); + var xming_command_key = Registry.GetValue(get_full_name(), "xming_command", null); + + if (xming_command_key == null) + { + Registry.SetValue(get_full_name(), "xming_command", "C:\\Program Files\\VcXsrv\\vcxsrv.exe\" :0 -clipboard -fullscreen -wgl"); + xming_command_key = Registry.GetValue(app_key_base + "\\" + Name, "xming_command", null); + } + this.XmingCommand = xming_command_key.ToString(); + if (command_key == null) { //insert key & set value @@ -128,6 +151,7 @@ public void pushToRegistry() Registry.SetValue(get_full_name(), "name", this.Name); Registry.SetValue(get_full_name(), "console", this.Console); Registry.SetValue(get_full_name(), "xming", this._usesXming.ToString()); + Registry.SetValue(get_full_name(), "xming_command", this._xmingCommand); } public void delete() diff --git a/BSCP/Configurator/MainWindow.xaml b/BSCP/Configurator/MainWindow.xaml index 934c3a7..6406a3b 100644 --- a/BSCP/Configurator/MainWindow.xaml +++ b/BSCP/Configurator/MainWindow.xaml @@ -39,6 +39,7 @@ +