diff --git a/Pilz.IO/Extensions.cs b/Pilz.IO/Extensions.cs
new file mode 100644
index 0000000..0cf41e2
--- /dev/null
+++ b/Pilz.IO/Extensions.cs
@@ -0,0 +1,26 @@
+using Pilz.Runtime;
+using Pilz.Win32.Native;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+
+namespace Pilz.IO
+{
+ public static class Extensions
+ {
+ static readonly int MAX_PATH = 255;
+
+ public static string GetExecutablePath(bool checkRealOS = false)
+ {
+ if (RuntimeInformationsEx.IsOSPlatform(OSType.Windows, checkRealOS))
+ {
+ var sb = new StringBuilder(MAX_PATH);
+ Kernel32.GetModuleFileName(IntPtr.Zero, sb, MAX_PATH);
+ return sb.ToString();
+ }
+ else
+ return Process.GetCurrentProcess().MainModule.FileName;
+ }
+ }
+}
diff --git a/Pilz.IO/Pilz.IO.csproj b/Pilz.IO/Pilz.IO.csproj
index 511e3a5..3b9bcb2 100644
--- a/Pilz.IO/Pilz.IO.csproj
+++ b/Pilz.IO/Pilz.IO.csproj
@@ -86,4 +86,8 @@
Application.Designer.cs
+
+
+
+
\ No newline at end of file
diff --git a/Pilz.Win32/Native/Kernel32.vb b/Pilz.Win32/Native/Kernel32.vb
new file mode 100644
index 0000000..0164502
--- /dev/null
+++ b/Pilz.Win32/Native/Kernel32.vb
@@ -0,0 +1,16 @@
+Imports System.Runtime.InteropServices
+Imports System.Text
+
+Namespace Native
+
+ Public Class Kernel32
+
+ Private Const LIB_KERNEL32 As String = "kernel32.dll"
+
+
+ Public Shared Function GetModuleFileName(hModule As IntPtr, lpFilename As StringBuilder, nSize As Integer) As UInteger
+ End Function
+
+ End Class
+
+End Namespace
diff --git a/Pilz.Win32/Native/User32.vb b/Pilz.Win32/Native/User32.vb
index d10c083..cf69991 100644
--- a/Pilz.Win32/Native/User32.vb
+++ b/Pilz.Win32/Native/User32.vb
@@ -4,11 +4,13 @@ Namespace Native
Public Class User32
-
+ Private Const LIB_USER32 As String = "user32.dll"
+
+
Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef r As RECT) As Boolean
End Function
-
+
Public Shared Function ChildWindowFromPointEx(ByVal hWndParent As IntPtr, ByVal pt As POINT, ByVal uFlags As UInteger) As IntPtr
End Function
diff --git a/Pilz/Runtime/RuntimeInformationsEx.vb b/Pilz/Runtime/RuntimeInformationsEx.vb
index d6f53c3..5e9ad7a 100644
--- a/Pilz/Runtime/RuntimeInformationsEx.vb
+++ b/Pilz/Runtime/RuntimeInformationsEx.vb
@@ -26,9 +26,9 @@ Namespace Runtime
End Get
End Property
- Public ReadOnly Property RealOSType As OSType
- Get
- Static t As OSType? = Nothing
+ Public ReadOnly Property RealOSType As OSType
+ Get
+ Static t As OSType? = Nothing
If t Is Nothing Then
@@ -69,9 +69,13 @@ Namespace Runtime
End If
Return t
- End Get
- End Property
+ End Get
+ End Property
- End Module
+ Public Function IsOSPlatform(os As OSType, checkRealOS As Boolean) As Boolean
+ Return If(checkRealOS, RealOSType, OSType) = os
+ End Function
+
+ End Module
End Namespace