RegAssociatedExec('.abc','abcfile','','','C:\Program.exe,0','C:\Program.exe %1');uses Registry, shlobj;function RegAssociatedExec(FileExt, Filetype, FileDescription, MIMEType, Icon, ExecName: String): Boolean; begin Result := False; if (FileExt = '') or (ExecName = '') then Exit; with TRegistry.Create do begin try RootKey:=HKEY_CLASSES_ROOT; if not OpenKey(FileExt, True) then Exit; WriteString('', FileType); if MIMEType <> '' then WriteString('Content Type', MIMEType); CloseKey; if not OpenKey(FileType, True) then Exit; WriteString('', FileDescription); CloseKey; if Icon<>'' then begin if not OpenKey(FileType+'\DefaultIcon', True) then Exit; WriteString('', Icon); CloseKey; end; if not OpenKey(FileType+'\Shell\Open\Command', True) then Exit; WriteString('', ExecName); CloseKey; SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil); finally Free; end; end; end; 其实不复杂,就是在注册表里处理一下,告诉系统扩展名(如“abc”)对应的键(如“abcfile”),在这个“abcfile”下面就有一些子键指定打开的程序和显示时使用的图标,完成更改注册表后,再告诉系统立即刷新一下就好了。
看到一扩展名的方法有所变化如下:
.doc 变为===> .docm
.xls 变为===> .xlsm
并“分析出对应打开这个文件的具体程序”
如下:
.txt 对应WinXPSP3系统中默认的打开文件为:notepad.exe
ExecName: String): Boolean;
begin
Result := False;
if (FileExt = '') or (ExecName = '') then
Exit; with TRegistry.Create do
begin
try
RootKey:=HKEY_CLASSES_ROOT;
if not OpenKey(FileExt, True) then
Exit; WriteString('', FileType);
if MIMEType <> '' then
WriteString('Content Type', MIMEType);
CloseKey; if not OpenKey(FileType, True) then
Exit;
WriteString('', FileDescription);
CloseKey; if Icon<>'' then
begin
if not OpenKey(FileType+'\DefaultIcon', True) then
Exit;
WriteString('', Icon);
CloseKey;
end; if not OpenKey(FileType+'\Shell\Open\Command', True) then
Exit;
WriteString('', ExecName);
CloseKey; SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
finally
Free;
end;
end;
end;
其实不复杂,就是在注册表里处理一下,告诉系统扩展名(如“abc”)对应的键(如“abcfile”),在这个“abcfile”下面就有一些子键指定打开的程序和显示时使用的图标,完成更改注册表后,再告诉系统立即刷新一下就好了。
//关联 相关扩展名 .abc
RegAssociatedExec('.abc','abcfile','','','C:\WINDOWS\notepad.exe,0','C:\WINDOWS\notepad.exe %1');
可是不知如何取消这个[注册标识]并初始化为[未识别的方式]
但是我想问的问题是: 我自己编写的[取消关联代码],就是直接删除[注册表]中
那些相关的[键值],为什么必须[重启系统或者重启Explorer.exe进程才会生效],
可是又关闭[状态栏上打开的所有文件夹]
1)用DELPHI读取EXE_DLL文件的相关参数
http://topic.csdn.net/u/20101030/16/f73fba3b-7e60-4490-a9ce-dbf07d157ee3.html
2)请教DELPHI编程实现“透明文件加密的问题 ”
http://topic.csdn.net/u/20110518/10/b6ba5f09-403a-4d2b-aced-23789ed16ad7.html
3)文件透明加密之驱动层驱开发问题请教
http://topic.csdn.net/u/20110613/10/f5123089-7ed9-4072-9918-283b86425ab5.html
4)用Delphi编写的EasySYS写驱动程序的问题
http://topic.csdn.net/u/20110616/14/ae342929-b1ad-4f9f-8481-a21b4d7c468d.html
5)用DELPHI编程如何调用这个.sys并显示:Hello World
http://topic.csdn.net/u/20110628/11/b13c130e-39c0-4e3d-b016-3844254e8e6d.html