比如我写了一个记事本程序
1.怎样才能编程实现txt文件与我的程序相关联?
2.怎样编程实现双击某个txt文件能使用我的程序打开并读出内容.(我试过选择打开方式指向我的程序后双击打开只能启动我的程序而读不出内容)
1.怎样才能编程实现txt文件与我的程序相关联?
2.怎样编程实现双击某个txt文件能使用我的程序打开并读出内容.(我试过选择打开方式指向我的程序后双击打开只能启动我的程序而读不出内容)
调试欢乐多
2、需要你的程序配合
HKEY_CLASSES_ROOT\WaferPainter.Document\shell\open\command = 你的程序EXE.EXE %1
HKEY_CLASSES_ROOT\WaferPainter.Document\shell\open\ddeexec = [open("%1")]
HKEY_CLASSES_ROOT\WaferPainter.Document\shell\open\ddeexec\application = 你的程序名
是RegCreateKey类似的操作的么?
2、需要在App的InitInstance中写EnableShellOpen();RegisterShellFileTypes(TRUE);必要时需重写OpenDocumentFile函数。
1. 文件扩展名关联文件类型
2. 创建文件类型的动作命令 比如ISO文件要关联程序daemon.exe 1. 文件扩展名关联文件类型 .iso -> ft000246
[HKEY_CLASSES_ROOT\.iso]
@="ft000246"
2. 创建文件类型的动作命令 ft000246
描述
[HKEY_CLASSES_ROOT\ft000246]
@="虚拟光盘" 图标
[HKEY_CLASSES_ROOT\ft000246\DefaultIcon]
@="D:\\Program Files\\D-Tools\\daemon.exe,0"
缺省动作
[HKEY_CLASSES_ROOT\ft000246\shell]
@="插入" [HKEY_CLASSES_ROOT\ft000246\shell\插入]
动作对应的命令行
[HKEY_CLASSES_ROOT\ft000246\shell\插入\command]
@="\"D:\\Program Files\\D-Tools\\daemon.exe\" -mount 0,\"%1\"" 这是最原始的方式
一般文件类型用ClassId 避免重复, 动作方式用DDE...3、
用记事本建一个a.reg文件,内容如下: [HKEY_CLASSES_ROOT\.aaa]
@="ABC.Document" [HKEY_CLASSES_ROOT\ABC.Document]
@="ABC.Document" [HKEY_CLASSES_ROOT\ABC.Document\CLSID]
@="{16301A11-0DE4-4BA1-A630-447B38862C97}" [HKEY_CLASSES_ROOT\ABC.Document\DefaultIcon]
@="f:\\ABC.exe,1" [HKEY_CLASSES_ROOT\ABC.Document\shell] [HKEY_CLASSES_ROOT\ABC.Document\shell\open] [HKEY_CLASSES_ROOT\ABC.Document\shell\open\command]
@="f:\\ABC.exe /dde" [HKEY_CLASSES_ROOT\ABC.Document\shell\open\ddeexec]
@="[open(\"%1\")]" [HKEY_CLASSES_ROOT\ABC.Document\shell\open\ddeexec\application]
@="ABC" [HKEY_CLASSES_ROOT\ABC.Document\shell\print] [HKEY_CLASSES_ROOT\ABC.Document\shell\print\command]
@="f:\\ABC.EXE /dde" [HKEY_CLASSES_ROOT\ABC.Document\shell\print\ddeexec]
@="[print(\"%1\")]" [HKEY_CLASSES_ROOT\ABC.Document\shell\printto] [HKEY_CLASSES_ROOT\ABC.Document\shell\printto\command]
@="f:\\ABC.exe /dde" [HKEY_CLASSES_ROOT\ABC.Document\shell\printto\ddeexec]
@="[printto(\"%1\",\"%2\",\"%3\",\"%4\")]" 假设你的ABC.EXE路径为f:\\ABC.exe,CLSID标识为"{18301A11-0DF4-4BA1-A630-447B35862C67}"