diff --git a/NibblePoker.Application.ListComPort/Program.cs b/NibblePoker.Application.ListComPort/Program.cs
index f2f377e..ab575d6 100644
--- a/NibblePoker.Application.ListComPort/Program.cs
+++ b/NibblePoker.Application.ListComPort/Program.cs
@@ -4,7 +4,7 @@ using NibblePoker.Library.ComPortWatcher;
namespace NibblePoker.Application.ListComPort;
internal static class Program {
- private const string Version = "3.0.0-indev";
+ private const string Version = "3.0.0";
private static readonly Verb RootVerb = new Verb("");
@@ -32,6 +32,15 @@ internal static class Program {
private static int _exitCode = ErrorCodes.NoError;
+ ///
+ /// Checks if the program is the only owner of its console.
+ /// This check is used to detect if the program was run from the exe/lnk or via a console.
+ ///
+ /// True if the process is the console's sole owner, False otherwise
+ private static bool IsProgramRunDirectly() {
+ return GetConsoleProcessList(new int[2], 2) <= 1;
+ }
+
private static int Main(string[] args) {
try {
ArgumentsParser.ParseArguments(RootVerb.RegisterOption(OptionShowAll).RegisterOption(OptionShowDevice)
@@ -52,6 +61,7 @@ internal static class Program {
Console.WriteLine("\nRemarks:");
Console.WriteLine(" * If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used.");
Console.WriteLine(" * If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown.");
+ Console.WriteLine(" * If the program is raw without going through a console, the options '-n' and '-f' will be used.");
Console.WriteLine(" * By default, the ports are sorted in the order they are provided by the registry, which is often chronological.");
Console.WriteLine(" * The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...)");
Console.WriteLine(" * The 'device name' refers to a port device path. (e.g.: \\Device\\Serial1, ...)");
@@ -90,12 +100,12 @@ internal static class Program {
_shouldPrintDeviceNames = true;
}
- if(OptionShowFriendly.WasUsed()) {
+ if(OptionShowFriendly.WasUsed() || IsProgramRunDirectly()) {
_shouldPrintRawNames = false;
_shouldPrintFriendlyNames = true;
}
- if(OptionShowNameRaw.WasUsed()) {
+ if(OptionShowNameRaw.WasUsed() || IsProgramRunDirectly()) {
_shouldPrintRawNames = true;
}
@@ -178,6 +188,17 @@ internal static class Program {
_exitCode = ErrorCodes.NoComPorts;
}
+ // Allows the program to be ran from a shortcut without closing the console instantly.
+ if(IsProgramRunDirectly()) {
+ Console.Write("\nPress any key to continue...");
+ Console.ReadKey();
+ }
+
return _exitCode;
}
+
+ // Imports "GetConsoleProcessList(...)" in order to know if the program was ran via a shortcut or CLI.
+ // See: https://learn.microsoft.com/en-us/windows/console/getconsoleprocesslist
+ [System.Runtime.InteropServices.DllImport("kernel32.dll")]
+ private static extern int GetConsoleProcessList(int[] buffer, int size);
}
diff --git a/NibblePoker.Packaging.ListComPort/ListComPort.wxs b/NibblePoker.Packaging.ListComPort/ListComPort.wxs
index 59b4808..9d19baf 100644
--- a/NibblePoker.Packaging.ListComPort/ListComPort.wxs
+++ b/NibblePoker.Packaging.ListComPort/ListComPort.wxs
@@ -7,7 +7,7 @@
-
-
-
+
+
diff --git a/NibblePoker.Packaging.ListComPort/en-us.wxl b/NibblePoker.Packaging.ListComPort/en-us.wxl
new file mode 100644
index 0000000..2ee4a59
--- /dev/null
+++ b/NibblePoker.Packaging.ListComPort/en-us.wxl
@@ -0,0 +1,7 @@
+
+
+
+ I accept the terms in these License Agreements and Privacy Statement
+
diff --git a/NibblePoker.Packaging.ListComPort/make.bat b/NibblePoker.Packaging.ListComPort/make.bat
index 17989d9..132292b 100644
--- a/NibblePoker.Packaging.ListComPort/make.bat
+++ b/NibblePoker.Packaging.ListComPort/make.bat
@@ -12,7 +12,7 @@ echo Executing "candle.exe" for x64...
"C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe" -nologo "ListComPort.wxs" -out "ListComPort_x64.wixobj" -ext WixUIExtension
echo Executing "light.exe" for x64...
-"C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x64.wixobj" -out "ListComPort_x64.msi" -ext WixUIExtension -cultures:en-us
+"C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x64.wixobj" -loc en-us.wxl -out "ListComPort_x64.msi" -ext WixUIExtension -cultures:en-us
set WixTargetPlatform=x86
@@ -20,7 +20,7 @@ echo Executing "candle.exe" for x86...
"C:\Program Files (x86)\WiX Toolset v3.14\bin\candle.exe" -nologo "ListComPort.wxs" -out "ListComPort_x86.wixobj" -ext WixUIExtension
echo Executing "light.exe" for x86...
-"C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x86.wixobj" -out "ListComPort_x86.msi" -ext WixUIExtension -cultures:en-us
+"C:\Program Files (x86)\WiX Toolset v3.14\bin\light.exe" "ListComPort_x86.wixobj" -loc en-us.wxl -out "ListComPort_x86.msi" -ext WixUIExtension -cultures:en-us
del *.wixobj
del *.wixpdb
diff --git a/readme.md b/readme.md
index 7f35463..900fb27 100644
--- a/readme.md
+++ b/readme.md
@@ -20,7 +20,8 @@ The latest releases can be found here: "*[Release page](https://github.com/azias
* Switched from *PureBasic* to *.NET 6.0*.
* Improved **a lot** of the program's logic.
* Added the `-h`/`--short-help`.
-* Added support for Windows ARM & ARM64
+* Added support for Windows ARM & ARM64.
+* Support for running without a console. (See [remarks](#remarks) #3)
## Usage
```
@@ -47,6 +48,7 @@ Launch arguments:
## Remarks
* If '-d' or '-f' is used, the raw name will not be shown unless '-n' is used.
* If '-D', '-t' or '-p' are used, the special separator between the raw and friendly name and the square brackets are not shown.
+* If the program is raw without going through a console, the options '-n' and '-f' will be used
* By default, the ports are sorted in the order they are provided by the registry, which is often chronological.
* The 'raw name' refers to a port name. (e.g.: COM1, COM2, ...)
* The 'device name' refers to a port device path. (e.g.: \Device\Serial1, ...)
@@ -91,9 +93,14 @@ You can simply clone the repository with the following command:
git clone https://github.com/aziascreations/DotNet-ListComPort.git
```
-Once this is done, you can compile it with the [compile.bat](compile.bat) script file.
+Once this is done, you can compile it with the [make.bat](make.bat) script file.
+
+Please note that you may need to have to edit your `PATH` or the aforementioned script
+so that 7-Zip and Wix Toolset v3.14 can be used by it.
+
+Finally, you should be able to find the executables in the "[Builds](Builds/)" folder,
+and the distributable packages in the "[Packages](Packages/)" folder.
-Finally, you should be able to find the executables in the "[Builds](Builds/)" folder.
## License
This project and all the libraries it uses are licensed under the [MIT](LICENSE) license.