src/modules/launcher/Plugins/Microsoft.Plugin.WindowWalker/Components/Window.cs
/// <summary>
/// Gets the name of the process using the window handle
/// </summary>
/// <param name="hwnd">The handle to the window</param>
/// <returns>A string representing the process name or an empty string if the function fails</returns>
Gets the name of the process using the window handle
Gets the name of the process using the window handle
private string GetProcessNameFromWindowHandle(IntPtr hwnd)
        {
            uint processId = GetProcessIDFromWindowHandle(hwnd);
            ProcessID = processId;
            IntPtr processHandle = InteropAndHelpers.OpenProcess(InteropAndHelpers.ProcessAccessFlags.AllAccess, true, (int)processId);
            StringBuilder processName = new StringBuilder(MaximumFileNameLength);
            if (InteropAndHelpers.GetProcessImageFileName(processHandle, processName, MaximumFileNameLength) != 0)
            {
                return processName.ToString().Split('\\').Reverse().ToArray()[0];
            }
            else
            {
                return string.Empty;
            }
        }
private string GetProcessNameFromWindowHandle ( IntPtr hwnd ) { uint processId = GetProcessIDFromWindowHandle ( hwnd ) ; ProcessID = processId ; IntPtr processHandle = InteropAndHelpers . OpenProcess ( InteropAndHelpers . ProcessAccessFlags . AllAccess , true , ( int ) processId ) ; StringBuilder processName = new StringBuilder ( MaximumFileNameLength ) ; if ( InteropAndHelpers . GetProcessImageFileName ( processHandle , processName , MaximumFileNameLength ) != 0 ) { return processName . ToString ( ) . Split ( ' \\ ' ) . Reverse ( ) . ToArray ( ) [ 0 ] ; } else { return string . Empty ; } }
Gets the name of the process using the window handle
Gets the name of the process using the window handle
A string representing the process name or an empty string if the function fails
A string representing the process name or an empty string if the function fails
hwnd
IntPtr
The handle to the window
The handle to the window