我给你个思路,可以最简单实现: 1. 用shellexec 打开你的url, 这时会进入ie, 调出页面 2. 向ie发消息,控制ie的menu, 让它选中 file, 再选中 save as 3. 现在就出现你要的对话框了
这个过程使用WEBBROWSER就可以实现啊.
用GetSaveFileName()MSDN解释如下:GetSaveFileName The GetSaveFileName function creates a Save common dialog box that lets the user specify the drive, directory, and name of a file to save. BOOL GetSaveFileName( LPOPENFILENAME lpofn // address of structure with initialization // data );
Parameters lpofn Pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetSaveFileName returns, this structure contains information about the user's file selection.
其中的 OPENFILENAME structure是:OPENFILENAME The OPENFILENAME structure contains information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As common dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure. typedef struct tagOFN { // ofn DWORD lStructSize; HWND hwndOwner; HINSTANCE hInstance; LPCTSTR lpstrFilter; LPTSTR lpstrCustomFilter; DWORD nMaxCustFilter; DWORD nFilterIndex; LPTSTR lpstrFile; DWORD nMaxFile; LPTSTR lpstrFileTitle; DWORD nMaxFileTitle; LPCTSTR lpstrInitialDir; LPCTSTR lpstrTitle; DWORD Flags; WORD nFileOffset; WORD nFileExtension; LPCTSTR lpstrDefExt; DWORD lCustData; LPOFNHOOKPROC lpfnHook; LPCTSTR lpTemplateName; } OPENFILENAME;
另外通过ie接口也可以实现,不过比较繁琐,也就不多说了!
我想用的是 ie中鼠标移到 URL上时点击右键出来的"目标另存为"的那个另存为
谢谢了,不知道它的OLECMDID是什么,
谢谢谢谢谢浪哥.......HELP~~~~!!!!!!
这个可以通过ie接口+菜单shell扩展相关的东西实现,我很久没做了,
等我看看msdn,在给你代码!
你通过Ihtmldocument2(通过webbrowser.document可以query到)接口的onmousedown事件得到点击的link的接口IhtmlLinkElement,通过这个接口得到点击的link的url,然后再创建一个隐藏的webbrowser去navigate这个url,相应它的OnDocumentComplete事件,在这个事件处理汉书中调用我上面提到的方法就可以保存了。
我想这不是最好的办法,ie接口里面肯定有相关接口,可是ie借口太多太复杂了,我一时也找不到,只能通过这种办法,我估计应该能行得通。
good luck
希望有高手能更好的解决一下了:)
我是想直接用它的那个下载对话框下载,懒的在做.
不知道该怎样去查ie的接口呢?
(不如教我怎样钓鱼先~~~~~~~~~~~~:)
怎样query document?
(webbrowser1。document as Ihtmldocument2)就可以得到接口了,并通过这个基本接口得到别的接口!记得包含mshtml。
webbrowser.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DODEFAULT, EmptyParam,emptyParam);
前面说了知道怎么用webbrowser了,
现在是不要用webbrowser!浪哥,我就是不会用接口啊............
该看哪方面的书呢?
如果这样用webbrowser不是就要下载页面?
可以不让webbrowser下载页面吗?
什么叫做一群笨蛋,自己看看前面的留言,你自己就明白了!:)
接口方面你得看com/activex方面的东西了哦!
begin
try
Result := UrlDownloadToFile(nil, PChar(SourceFile),
PChar(DestFile), 0, nil) = 0;
except
Result := False;
end;
end;
但是这个没有IE里的那个提示啊,下载一个大文件的话就定在那里了...:(还是IE那个好啊.....真想拿来就用,不知道上哪拿去.......唉.刚买了一套MSDN,3张盘的.研究中...........................................
可是shell不就那几个read,open,...命令吗?
还有msdn没有说明的命令吗?
....?
1. 用shellexec 打开你的url, 这时会进入ie, 调出页面
2. 向ie发消息,控制ie的menu, 让它选中 file, 再选中 save as
3. 现在就出现你要的对话框了
The GetSaveFileName function creates a Save common dialog box that lets the user specify the drive, directory, and name of a file to save. BOOL GetSaveFileName(
LPOPENFILENAME lpofn // address of structure with initialization
// data
);
Parameters
lpofn
Pointer to an OPENFILENAME structure that contains information used to initialize the dialog box. When GetSaveFileName returns, this structure contains information about the user's file selection.
The OPENFILENAME structure contains information that the GetOpenFileName and GetSaveFileName functions use to initialize an Open or Save As common dialog box. After the user closes the dialog box, the system returns information about the user's selection in this structure. typedef struct tagOFN { // ofn
DWORD lStructSize;
HWND hwndOwner;
HINSTANCE hInstance;
LPCTSTR lpstrFilter;
LPTSTR lpstrCustomFilter;
DWORD nMaxCustFilter;
DWORD nFilterIndex;
LPTSTR lpstrFile;
DWORD nMaxFile;
LPTSTR lpstrFileTitle;
DWORD nMaxFileTitle;
LPCTSTR lpstrInitialDir;
LPCTSTR lpstrTitle;
DWORD Flags;
WORD nFileOffset;
WORD nFileExtension;
LPCTSTR lpstrDefExt;
DWORD lCustData;
LPOFNHOOKPROC lpfnHook;
LPCTSTR lpTemplateName;
} OPENFILENAME;