关于根据文件类型列出相应执行程序的。

dolphi 2002-03-11 11:05:25

打开资源管理器。在一个文件上单击右健,Popup菜单里会有 “打开方式”一栏,里面会列出可用于打开该文件的应用程序。例如:*.JPG。在打开方式里一般可以看到:

Internet Explorer
Microsoft Paint
图像处理
Photoshop
....

请问如何通过编程实现类似功能?我知道用FindExecutable()可以得到用于打开文档的默认执行程序的文件名和路径。但我要的是所有已注册可打开该文件的可执行程序以及其别名。
...全文
77 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
我看了一下WIN2K的也是如此。
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
我的是WIN98
dolphi 2002-03-11
  • 打赏
  • 举报
回复
如果是*.DOC
菜单里会是这样的:

Microsoft Word for Windows
Internet Explorer
写字板
-----------------
选择程序...

它列出来的程序都是可以打开相关文件的。

dolphi 2002-03-11
  • 打赏
  • 举报
回复
你用的是什么操作系统?
《打开方式》是一个子菜单,里面列出了能够打开该文件的相关程序。例如选择*.bmp。菜单里会是这样的:

Microsoft Paint
Internet Explorer
-----------------
选择程序...

其中《选择程序》是一个命令,将打开所有注册的应用程序供你挑选。
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
打开方式中列出的并不是能找开此文件的所有程序,它只是列出那些文件让你选择一个可以找开它的,然后进行关联。
dolphi 2002-03-11
  • 打赏
  • 举报
回复

没有记录?不可能吧?那么资源浏览器怎么知道那些可以打开?这是从windows 98开始就实现的功能了。
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
Windows记载的只有默认的,至于能不能用其它软件打开,Windows并没有记录,就象你所举的例子,Windows也只会用一种软件来打开它,别的能不能打开要人为的去试一试才能知道。比方说jpg默认用IE打开,MS Paint呢,你要用它Open一下才知道它不能打开,图像处理呢,也要Open一下才知道它能打开。
westfly 2002-03-11
  • 打赏
  • 举报
回复
Ret:=ShellExecute(Handle, 'open', FileName, nil, FilePath, 0);
if Ret = SE_ERR_NOASSOC then
ShellExecute(
Handle,
nil,
'rundll32.exe',
StrCat('shell32.dll,OpenAs_RunDLL ', FileName),
FilePath
SW_SHOWNORMAL
);
dolphi 2002-03-11
  • 打赏
  • 举报
回复
up
dolphi 2002-03-11
  • 打赏
  • 举报
回复
谢谢你,不过只能找到默认的打开方式,不能得到所有可打开的应用程序啊。
你说的方法直接用ShellExecute就可以打开了。
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
查注册表不就完了,
比方说txt先打开HKEY_CLASSES_ROOT下的.txt一项得到它的默认值txtfile,
然后再打开txtfile\shell\open\command看看它是什么值不就可以了。
dolphi 2002-03-11
  • 打赏
  • 举报
回复
谢谢。我就是看MSDN的。有时候一些内容愣是找不到,没法子。有人提醒一下就好多了。我已经完成了,谢谢你。
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
这个说明是放在执行文件中的,下面给你一个简单的例子吧,最好是看看一MSDN或MD SDK的文档。
procedure TForm1.Button1Click(Sender: TObject);
var
dwVerInfoSize, dwVerHnd: DWORD;
hMem: THandle;
lpvMem, lszVer: Pointer;
szGetName: array[0..255] of Char;
cchVer: UINT;
fRet: Boolean;
ab: array[0..255] of Byte;
begin
dwVerInfoSize := GetFileVersionInfoSize('Shell32.dll', dwVerHnd);
if Boolean(dwVerInfoSize) then
begin
hMem := GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
lpvMem := GlobalLock(hMem);
GetFileVersionInfo('Calc.exe', dwVerHnd, dwVerInfoSize, lpvMem);
StrCopy(szGetName, '\VarFileInfo\Translation');
lszVer := nil;
fRet := VerQueryValue(lpvMem, szGetName, lszVer, cchVer);
if fRet and Boolean(cchVer) and Boolean(lszVer) then
begin
StrCopy(@ab, lszVer);
StrCopy(szGetName, PChar('\StringFileInfo\' +
IntToHex(ab[2] + ab[3] * $100 + ab[0] * $10000 + ab[1] * $1000000, 8) +
'\FileDescription'));
lszVer := nil;
fRet := VerQueryValue(lpvMem, szGetName, lszVer, cchVer);
if fRet and Boolean(cchVer) and Boolean(lszVer) then
ShowMessage(PChar(lszVer));
end;
GlobalUnlock(hMem);
GlobalFree(hMem);
end;
end;
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
这个说明是放在执行文件中的,下面给你一个简单的例子吧,最好是看看一MSDN或MD SDK的文档。
procedure TForm1.Button1Click(Sender: TObject);
var
dwVerInfoSize, dwVerHnd: DWORD;
hMem: THandle;
lpvMem, lszVer: Pointer;
szGetName: array[0..255] of Char;
cchVer: UINT;
fRet: Boolean;
ab: array[0..255] of Byte;
begin
dwVerInfoSize := GetFileVersionInfoSize('Shell32.dll', dwVerHnd);
if Boolean(dwVerInfoSize) then
begin
hMem := GlobalAlloc(GMEM_MOVEABLE, dwVerInfoSize);
lpvMem := GlobalLock(hMem);
GetFileVersionInfo('Calc.exe', dwVerHnd, dwVerInfoSize, lpvMem);
StrCopy(szGetName, '\VarFileInfo\Translation');
lszVer := nil;
fRet := VerQueryValue(lpvMem, szGetName, lszVer, cchVer);
if fRet and Boolean(cchVer) and Boolean(lszVer) then
begin
StrCopy(@ab, lszVer);
StrCopy(szGetName, PChar('\StringFileInfo\' +
IntToHex(ab[2] + ab[3] * $100 + ab[0] * $10000 + ab[1] * $1000000, 8) +
'\FileDescription'));
lszVer := nil;
fRet := VerQueryValue(lpvMem, szGetName, lszVer, cchVer);
if fRet and Boolean(cchVer) and Boolean(lszVer) then
ShowMessage(PChar(lszVer));
end;
GlobalUnlock(hMem);
GlobalFree(hMem);
end;
end;
dolphi 2002-03-11
  • 打赏
  • 举报
回复
顺便问一个问题。我怎么样得到一个应用程序的说明?
例如在资源管理器里查看 winword.exe的属性,它的说明是:Microsoft Word for Windows。

另外一个问题,我有一个贴子所有人都没答上来,我想不给分结贴,怎么做?
dolphi 2002-03-11
  • 打赏
  • 举报
回复
对对对!我要的就是这个!谢谢你啦。100分是你的啦(妈妈怎么我查不到,哎~~)。
prometheusphinx 2002-03-11
  • 打赏
  • 举报
回复
老弟,你说的那种现象只有在你将一个文件关联了多个打开程序时才会有,
这个信息是放在HKEY_CURRENT_USRE\ S o f t w a r e \ M i c r o s o f t \ W i n d o w s \ C u r r e n t V e r s i o n \ E x p l o r e r \ F i l e E x t s \的下面
dolphi 2002-03-11
  • 打赏
  • 举报
回复
up
dolphi 2002-03-11
  • 打赏
  • 举报
回复
我的w2k就是我说的那样子。是不是咱们的交流有问题?或者你问问别人吧。

5,930

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧