首页  编辑  

创建DDE程序解决打开IE临时文件问题

Tags: /超级猛料/COM、ActiveX,DDE/DDE/   Date Created:
创建DDE程序解决打开IE临时文件问题
How to "open" a IE download file ?
Keywords: DDE, Delphi, Internet Explorer, Cache, Tempory, Open
By Kingron, 2006
Q (Anthoni):
I have my application registering an extension so that when you double click
on a file it will open in the application. This works perfectly.
However, when I click on a url in IE like
www.myweb.com/myfile.ext and IE asks if I want to download or open, I click
open, the path and subsequent file name I get can not be accessed. I've
tried enumerating the "Tempory Internet Folder" as per this article
http://www.swissdelphicenter.ch/torry/showcode.php?id=2364 but nothing. It
gets the URL it came from but not the file itself, so I know the file
downloaded properly.
If I do the same thing in Netscape or Firefox then the file gets downloaded
to the Temp drawer and I can open it from there. It's just IE that is being
a pain and not giving me the right information.
Anyone know what I am doing wrong?
I've seen other programs that handle this perfectly, so it can be done, I
just must be missing something.
Any help is much appreciated.
Regards
"Cannot find the file '<my file>' (or one of its components). Make sure the path and filename are correct and that all required libraries are available."
问题的意思就是自己注册了某个文件类型,在资源管理器,Firefox,Netscape中可以点击某个连接,直接选择"Open"打开文件,但是使用IE点击某个连接,选择直接打开文件,却无法正常打开文件。
A (Kingron):
Please use DDE to solve it. Register your file type first, and use DDE like the figure. and please place TddeServerItem, TddeServerConv to your form and set the properties as below:
TDdeServerConv.Name = 'system'
TDdeServerItem.ServerConv = TDdeServerConv
TDdeServerItem.Name = 'Open'
then you can open the file correctly when you click "open" in Internet explorer.
IE在下载完成后,会调用关联的程序来打开文件,并且会删除Cache中的文件,导致程序不能正常打开文件。IE使用了DDE来通知程序打开文件,如果你的程序支持DDE,那么你的程序可以在DDE消息处理中打开文件,并且文件不会被删除。
需要DDE来解决这个问题。首先关联你的程序,并且注册DDE,例如:

其中DDE消息"Open"和主题"System"是我们要用到的数据!
在自己的程序中,放置一个TDdeServerItem,TDdeServerConv,并设置如下:
TDdeServerConv.Name = 'system'
TDdeServerItem.ServerConv = TDdeServerConv
TDdeServerItem.Name = 'Open'
然后就可以正常打开文件了。
如果不做上面的设置,那么打开文件的时候会报一个"找不到文件"的错误!

img_4417.bmp (463.6KB)