如何获取在记事本中打开的文件的文件名和路径? [英] How to get filename and path of file opened in Notepad?

查看:30
本文介绍了如何获取在记事本中打开的文件的文件名和路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过记事本中打开的文件的路径获取名称.我已经有了 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.

这篇关于如何获取在记事本中打开的文件的文件名和路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆