diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs index 08e1b4143bc..22e9c6919d4 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/DpiUtil/DpiUtil+ProcessDpiAwarenessHelper.cs @@ -99,7 +99,7 @@ private static PROCESS_DPI_AWARENESS GetProcessDpiAwarenessFromWindow(IntPtr hWn { // If a valid window is not specified, then query the current process instead of the process // associated with the window - windowThreadProcessId = SafeNativeMethods.GetCurrentProcessId(); + windowThreadProcessId = Environment.ProcessId; } Debug.Assert(windowThreadProcessId != 0, "GetWindowThreadProcessId failed"); diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs index 2689a08b655..506c64037ad 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Automation/Peers/AutomationPeer.cs @@ -1466,7 +1466,7 @@ public void ResetChildrenCache() /// internal int[] GetRuntimeId() { - return new int [] { 7, SafeNativeMethods.GetCurrentProcessId(), this.GetHashCode() }; + return new int [] { 7, Environment.ProcessId, this.GetHashCode() }; } /// @@ -2500,7 +2500,7 @@ internal PatternInfo(int id, WrapObject wrapObject, PatternInterface patternInte private static object IsKeyboardFocusable(AutomationPeer peer) { return peer.IsKeyboardFocusable(); } private static object IsEnabled(AutomationPeer peer) { return peer.IsEnabled(); } private static object GetBoundingRectangle(AutomationPeer peer) { return peer.GetBoundingRectangle(); } - private static object GetCurrentProcessId(AutomationPeer peer) { return SafeNativeMethods.GetCurrentProcessId(); } + private static object GetCurrentProcessId(AutomationPeer peer) { return Environment.ProcessId; } private static object GetRuntimeId(AutomationPeer peer) { return peer.GetRuntimeId(); } private static object GetClassName(AutomationPeer peer) { return peer.GetClassName(); } private static object GetHelpText(AutomationPeer peer) { return peer.GetHelpText(); } diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs index 06fa04b9ff5..0b8cb19e175 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/InterOp/HwndTarget.cs @@ -542,7 +542,7 @@ out processId "hwnd" ); } - else if (processId != SafeNativeMethods.GetCurrentProcessId()) + else if (processId != Environment.ProcessId) { throw new ArgumentException( SR.HwndTarget_InvalidWindowProcess, diff --git a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs index 6a1008caa7a..9da4a5fc08d 100644 --- a/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs +++ b/src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Interop/HwndHost.cs @@ -1053,7 +1053,7 @@ private void BuildWindow(HandleRef hwndParent) (idWindowProcess == UnsafeNativeMethods.GetProcessIdOfThread(hCurrentThread))) #else if ((idWindowThread == SafeNativeMethods.GetCurrentThreadId()) && - (idWindowProcess == SafeNativeMethods.GetCurrentProcessId())) + (idWindowProcess == Environment.ProcessId)) #endif { _hwndSubclass = new HwndSubclass(_hwndSubclassHook); diff --git a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs index 46fb47a0c2d..a0d364afbaf 100644 --- a/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs +++ b/src/Microsoft.DotNet.Wpf/src/Shared/MS/Win32/SafeNativeMethodsCLR.cs @@ -267,12 +267,6 @@ public static void ScreenToClient(HandleRef hWnd, ref NativeMethods.POINT pt) } } - public static int GetCurrentProcessId() - { - return SafeNativeMethodsPrivate.GetCurrentProcessId(); - } - - public static int GetCurrentThreadId() { return SafeNativeMethodsPrivate.GetCurrentThreadId(); @@ -290,7 +284,7 @@ public static int GetCurrentThreadId() int sessionId; if (SafeNativeMethodsPrivate.ProcessIdToSessionId( - GetCurrentProcessId(), out sessionId)) + Environment.ProcessId, out sessionId)) { result = sessionId; } @@ -618,9 +612,6 @@ internal static bool PhysicalToLogicalPointForPerMonitorDPI( private partial class SafeNativeMethodsPrivate { - [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)] - public static extern int GetCurrentProcessId(); - [DllImport(ExternDll.Kernel32, ExactSpelling = true, CharSet = CharSet.Auto)] [return:MarshalAs(UnmanagedType.Bool)] public static extern bool ProcessIdToSessionId([In]int dwProcessId, [Out]out int pSessionId); diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs index ec91124aedb..4b168a68fc1 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/Accessible.cs @@ -164,7 +164,7 @@ internal static Accessible CreateNativeFromEvent(IntPtr hwnd, int idObject, int // DuplicateHandle back to this process.) IntPtr wParam = IntPtr.Zero; if(Environment.OSVersion.Version.Major >= 6) - wParam = new IntPtr(UnsafeNativeMethods.GetCurrentProcessId()); + wParam = new IntPtr(Environment.ProcessId); // send the window a WM_GETOBJECT message requesting the specific object id. IntPtr lResult = Misc.ProxySendMessage(hwnd, NativeMethods.WM_GETOBJECT, wParam, new IntPtr(idObject)); diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeProcessHandle.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeProcessHandle.cs index 5fa7c0c73bb..f60c2543398 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeProcessHandle.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Internal/AutomationProxies/SafeProcessHandle.cs @@ -25,7 +25,7 @@ internal SafeProcessHandle(IntPtr hwnd) : base(true) if (hwnd == IntPtr.Zero) { - processId = UnsafeNativeMethods.GetCurrentProcessId(); + processId = (uint)Environment.ProcessId; } else { diff --git a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/UnsafeNativeMethods.cs b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/UnsafeNativeMethods.cs index e33a118e51c..0a160d1d82b 100644 --- a/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/UnsafeNativeMethods.cs +++ b/src/Microsoft.DotNet.Wpf/src/UIAutomation/UIAutomationClientSideProviders/MS/Win32/UnsafeNativeMethods.cs @@ -33,8 +33,6 @@ internal static class UnsafeNativeMethods [DllImport(ExternDll.Kernel32, SetLastError = true)] internal static extern IntPtr OpenProcess(int flags, bool inherit, uint dwProcessId); - [DllImport(ExternDll.Kernel32)] - public static extern uint GetCurrentProcessId(); [DllImport(ExternDll.Kernel32)] internal static extern void GetSystemInfo(out NativeMethods.SYSTEM_INFO SystemInfo); [DllImport(ExternDll.Kernel32, SetLastError = true)]