How do I GetModuleFileName() if I only have a window handle (hWnd)?

前端 未结 5 2081
误落风尘
误落风尘 2020-12-15 11:11

I\'m trying to get the name of the executable of a window that is outside my C# 2.0 application. My app currently gets a window handle (hWnd) using the GetForegroundWindow()

5条回答
  •  生来不讨喜
    2020-12-15 12:00

    You can call GetWindowThreadProcessId and that will return you the process associated with the window.

    From that, you can call OpenProcess to open the process and get the handle to the process.

提交回复
热议问题