设计文本编辑器 [英] designing a text editor

查看:83
本文介绍了设计文本编辑器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在Windows上的C语言中设计文本编辑器时,当用户双击我的编辑器可执行文件时,它会打开一个文本编辑器,以允许用户键入内容,然后将其保存为test.xyz文件扩展名.

完成此步骤后,当用户双击桌面直接打开test.xyz文件时,如何使用texteditor.exe编辑器自动打开test.xyz文件.

我之所以这样问是因为我以唯一的格式存储test.xyz文件的内容,只有我的testitor.exe才能以正确的方式理解并解释该内容.

如何将此功能嵌入到testitor的源代码中,以便用户无需打开testitor,而是可以直接打开.xyz文档,然后在testitor中自动查看此文件.

例如,如果单击.doc文件,它将自动以MS Word而不是记事本打开.

Hi,
While designing a text editor in C on windows, when the user double clicks on my editor executable it opens a text editor to allow the user to type-in and then save it with a test.xyz file extension.

After this step the when the user directly opens test.xyz file by double clicking on desktop, how do I make the test.xyz file open with my texteditor.exe editor automatically.

I am asking this because I store the contents of the test.xyz file in a unique format that only my testeditor.exe can understand and interpret the contents to user in a correct way.

How to embed this feature in in testeditor source code so that the user need not open the testeditor but instead he can directly open the .xyz documents and then automatically view this file in testeditor.

For example, if you click on a .doc file it automatically opens in MS word instead of notepad.

Any clues to this will be appreciated.

推荐答案

它有两个部分:您的应用程序功能+与Shell相关的系统注册表设置.

在应用程序部分,您需要处理在启动时传递给您的应用程序的命令行参数.因为这是C,所以您有一个名为main的入口点.应用程序的OS加载程序传递命令行参数argcargv,它们出现在以下签名中的一个
There are two parts of it: your application functionality + system registry settings related to the Shell.

On application part, you need to handle the command line parameters passed to your application when it is started. As this is C, you have an entry point called main. The OS loader of the applications passes the command line parameters argc, and argv as they appear in on of the following signatures
int main(int argc, char **argv);
int main(int argc, char *argv[]);
int main(int argc, char **argv, char **envp);



请参阅:
http://en.wikipedia.org/wiki/Main_function#C_and_C.2B.2B [ ^ ].

您的应用程序应解析命令行,识别文件名并尝试加载文件.

在系统注册表方面,您需要更新寄存器以注册您的应用程序与文件名模式(通常称为扩展名")识别的某些文件类型之间的关联,但该术语不正确:没有扩展名" 在现代文件系统中;文件名中最后一个".字符后的字母只是文件名的一部分).请参阅:
http://msdn.microsoft.com/zh-我们/library/windows/desktop/cc144158%28v=vs.85%29.aspx [ http://msdn.microsoft.com/zh-我们/library/windows/desktop/cc144156%28v=vs.85%29.aspx [



Please see:
http://en.wikipedia.org/wiki/Main_function#C_and_C.2B.2B[^].

Your application should parse the command line, recognize file name(s) and try to load a file.

On the system registry side, you need to update the register to register the association between your application and some file type(s) recognized by the file name pattern (usually called "extensions", but this term is incorrect: there are no "extensions" in modern file systems; the letters after the last ''.'' character in file names are just the part of the file name). Please see:
http://msdn.microsoft.com/en-us/library/windows/desktop/cc144158%28v=vs.85%29.aspx[^],
http://msdn.microsoft.com/en-us/library/windows/desktop/cc144156%28v=vs.85%29.aspx[^].

—SA


这篇关于设计文本编辑器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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