如何获取在记事本中打开的文件的文件名和路径?

问题描述:

是否可以通过记事本中打开的文件的路径获取名称.我已经有了 Notepad.exe 的 ProcessId.

Is it possible to get name with path of a file opened in Notepad. I already have ProcessId of the Notepad.exe.

谢谢,导航

是标题栏的一部分,所以需要获取窗口句柄然后调用Win API函数GetWindowText()

It's part of the title bar, so you need to get the window handle and then call the Win API function GetWindowText()

这可能就是您想要的:使用 Process 对象获取正确的窗口标题.

MSDN GetWindowText

如评论中所述,这并未提供完整路径.

As mentioned in the comments, this doesn't give the full path.