问题:我想象Word和Excel一样。一双击文档文件就打开我的程序,并自动调用这个文档内容 ( 积分:200, 回复:5, 阅读:31 ) 分类:包装发布 ( 版主:雁孤行, OopsWare ) | 来自:田伯光, 时间:2004-8-15 20:21:00, ID:2765310 | [显示:小字体 | 大字体] |
不知道要如何处理,望各位大哥大姐给予指导,将不慎感谢。
最好能提供全部过程,包括在WINDOWS中注册。和程序的处理方式。
来自:
lmz123,
时间:2004-8-15 21:57:54,
ID:2765376
你的文档和程序是配套使用的吗,即你的文档只能由你写的程序打开
如是这样,建立文档和程序关联即可。
来自:
kaida,
时间:2004-8-15 22:22:34,
ID:2765388
uses registry;
.....
Var
Reg : TRegistry;
Begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
OpenKey('\MyApp', True);
WriteString('', 'MyApp File');
CloseKey;
OpenKey('MyApp\DefaultIcon', True);
WriteString('', Application.ExeName + ',0'); //应用程序注册图标
CloseKey;
OpenKey('MyApp\shell\open\command', True);
WriteString('', Application.ExeName + ' "%1"');
CloseKey;
RootKey := HKEY_CLASSES_ROOT;
OpenKey('\.ext', True); // .ext -》你要关联的文件扩展名
WriteString('', 'MyApp');
CloseKey;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
End;
来自:
田伯光,
时间:2004-8-15 22:55:02,
ID:2765424
那怎么在程序中处理呢,是否要个接口函数在双击该图标以后吧所有数据读入。如果只是单纯打开的话并不能完全实现类似WORD的功能。
多谢多谢。
来自:
kaida,
时间:2004-8-16 0:28:27,
ID:2765478
上面代码是将你的程序和你程序使用的文件扩展名进行注册。只要在你的程序中调用一次即可。之后,双击具有你指定扩展名的文件时,就会自动打开你的应用程序,并将你双击的文件作为命令行参数传递给你的程序。因此你的程序必须对命令行参数进行判断和操作才行。
来自:
田伯光,
时间:2004-8-16 16:57:52,
ID:2766709
接受答案了.
| 得分大富翁:kaida |
自己改了的:
procedure TFlashExplorer.RegFlashLine(var appname, ext, icon: string);{appname 是要注册的程序名字,不是文件名 ,ext是要关联的后缀,如 '.yue' ,icon 是注册文件的图标,可以写成 application.exename+',0' }
Var
Reg : TRegistry;
Begin
Reg := TRegistry.Create;
try
with Reg do
begin
RootKey := HKEY_CLASSES_ROOT;
OpenKey('\'+appname, True);
WriteString('',appname+' File');
CloseKey;
OpenKey(appname+'\DefaultIcon', True);
WriteString('',icon); //应用程序注册图标
CloseKey;
OpenKey(appname+'\shell\open\command', True);
WriteString('', Application.ExeName + ' "%1"');//此处的%1的1是告诉系统传递参数的号,看下面读取参数部分
CloseKey;
RootKey := HKEY_CLASSES_ROOT;
OpenKey('\'+ext, True); // .ext -》你要关联的文件扩展名
WriteString('', appname);
CloseKey;
end;
finally
Reg.CloseKey;
Reg.Free;
end;
End;
读取参数:
var
filename:string
begin
filename:=paramstr(1);
//这里filename就是参数拉
end;
|