使用不同的文本编辑器打开文件
显然这应该是可能的。例如,使用记事本或 HxD 打开和操作文件。但它们不都是文本文件吗...如何指定哪个文本编辑器打开文件并使用 WINDOWS API 操作文件。它肯定不在“CreateFile”中。
Apparently this supposed to be possible. For example opening and operating on a file with NOTEPAD, or HxD. But aren't they all text files...how would one specify which text editor to open the file and operate on the file with using the WINDOWS API. It is certainly not in "CreateFile".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
希望我理解你的问题...最简单的方法是启动所需的编辑器并将文件名作为参数传递,而不是“调用”文件(这将启动与文件类型关联的默认程序) 。
例如,
notepad.exe mytextfile.txt
或gvim.exe mytextfile.txt
。如果编辑器不在您的
%PATH%
上,您将需要使用完整路径文件名。Hopefully I'm understanding your question... The easiest way to do this is to launch the desired editor and pass the filename as an argument, rather than "invoking" the file (which will launch the default program associated with the file type).
For example,
notepad.exe mytextfile.txt
orgvim.exe mytextfile.txt
.If the editor is not on your
%PATH%
, you'll need to use a full path file name.你到底想做什么?您可以:
RegGetValue
),并使用CreateProcess
启动编辑器)(更好一点)创建进程
。 (最好的主意)但这一切都取决于您的真正目标是什么。
根据要求进行编辑
因此,我们在同一页面上,从 C++ 中,您希望:
正确吗?
如果是这样,您可以:
当然,您必须处理各种问题(这只是描述我可能使用的算法的一种超级简单的方式),例如:
我确信有许多不同的方法可以做到这一点,但这是我目前能想到的最简单的方法(同时仍然能够相当确定更改)。
免责声明:我还没有实现类似的东西,所以我可能完全没有根据;)
What are you trying to do, exactly? You could:
RegGetValue
), and launch the editor withCreateProcess
) (a little better idea)CreateProcess
. (best idea)But it all depends on what your goal is really.
Edit based on requirements
So, just so we're on the same page, from C++, you want to:
Is that correct?
If so, you could:
sleep
so you don't chew up resources while the initially computed CRC matches one calculated every iteration of the loopOf course, there are all kinds of issues that you'd have to deal with (that's just a super simple way of describing the algorithm I might use), such as:
I'm sure that there are a number of different methods of doing this, but this is the easiest method that I can think of at the moment (while still being able to be fairly certain of the changes).
Disclaimer: I haven't implemented something like this, so I might be completely off base ;)
您是否在寻找
ShellExecute()
或 Windows 上的ShellExecuteEx()
API?他们将启动为文件注册的任何程序(通常基于文件名扩展名)。Are you looking for the
ShellExecute()
orShellExecuteEx()
APIs on Windows? They'll launch whatever program is registered for a file (generally based on the filename extention).