怎么能存成。mht文件呢?网页是很多文件的组合啊,假如非要存成一个文件,不如截图吧:)
解决方案 »
- 一個Delphi菜鳥的問題(twwdbgrid用法)
- 一个dbgrid和一个adodataset,如何才能取消在移动dbgrid中的行焦点时更新到数据库,而是等我点击了窗口上一个按钮才更新到数据库???
- 在sql server中,如何创建一个字增自段?(最好用可视化方法!)
- 我用application.messagebox(edit_memo.text,'提示信息',mb_ok+mb_iconinformation);我想让消息窗口的内容为edit_memo中的所输入的。但是
- 已知一个汉字,如何快速的查询出他的拼音,给点建议
- 请问delphi6的注册码是什么,谢谢
- 初学者做的一个远程文件浏览器,请高手指点!!
- 怎么样得到系统的当前时间?
- 在Delphi6中如何调用执行另一个exe文件,是不是有个函数?或者调用哪个api?
- DELPHI调用VC中DLL
- help me:http://www.csdn.net/expert/topic/373/373660.shtm
- 急,高手请进........SQLSERVER 中表的导入及导出...............Holen
我要在程序中动态给出文件名进行存储,还有哪位大侠可以教我。
--------------------------------
procedure TForm1.SaveHTMLSourceToFile(const FileName: string;
WB: TWebBrowser);
var
PersistStream: IPersistStreamInit;
FileStream: TFileStream;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
FileStream := TFileStream.Create(FileName, fmCreate);
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
if FAILED(SaveResult) then
MessageBox(Handle, 'Fail to save HTML source', 'Error', 0);
finally
{ we are passing soReference in TStreamAdapter constructor,
it is our responsibility to destroy the TFileStream object. }
FileStream.Free;
end;
end; pocedure TForm1.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
SaveHTMLSourceToFile(SaveDialog1.FileName, WebBrowser1);
end;
var
PersistStream: IPersistStreamInit;
Stream: IStream;
上面是你定义的变量,但上面这两句我的Delphi编不过去,你能不能给我一个完整点的代码,起码把你的Uses段的东西给我,谢谢了!
另外,加分是没有问题的,我可以出到300分,或更高也行。
你这种方法可以存下一个网页的原码,但我要的是存下所有文字和图片,由其是图片,你的程序中好象没有,只是有连接,不过还是要谢谢你能给我回话。可是,我的问题还是没有解决。
请各位大侠们快来帮忙呀!!!
----------------------------------
procedure TForm1.Button3Click(Sender: TObject);
var
Vin,Vout : OleVariant;
begin
vin:='';
vout:='';
WebBrowser1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DODEFAULT,vin, vout);
end;
存一个网页搞那么复杂干什么?
用IE的另存功能吧。存为html的文件。
图片之类全都会安置好。
再采用winzip压缩,压缩后做成exe文件。不就是一个文件了吗?呵呵。
我所需要的就是这个意思,但还有一个问题是,我不能要存档这个窗体,我需要在程序中指定出文件名,然后直接存档,请问有没有办法,再次谢谢你。也请其他高手帮我一把!
WebBrowser1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DODEFAULT,vin, vout);
有没有人可以把上面这条语句的SAVE窗口去掉。
一些击键信息,然后再调用该save窗口。由于很快速,save窗口是看不见的。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw, activeX;type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Button1: TButton;
SaveDialog1: TSaveDialog;
Button2: TButton;
Button3: TButton; procedure SaveHTMLSourceToFile(const FileName: string;WB: TWebBrowser);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure SimulateKeyDown(Key : byte);
begin
keybd_event(Key, 0, 0, 0);
end;procedure SimulateKeyUp(Key : byte);
begin
keybd_event(Key, 0, KEYEVENTF_KEYUP, 0);
end;procedure SimulateKeystroke(Key : byte;
extra : DWORD);
begin
keybd_event(Key,
extra,
0,
0);
keybd_event(Key,
extra,
KEYEVENTF_KEYUP,
0);
end;procedure SendKeys(s : string);
var
i : integer;
flag : bool;
w : word;
begin
{Get the state of the caps lock key}
flag := not GetKeyState(VK_CAPITAL) and 1 = 0;
{If the caps lock key is on then turn it off}
if flag then
SimulateKeystroke(VK_CAPITAL, 0);
for i := 1 to Length(s) do begin
w := VkKeyScan(s[i]);
{If there is not an error in the key translation}
if ((HiByte(w) <> $FF) and
(LoByte(w) <> $FF)) then begin
{If the key requires the shift key down - hold it down}
if HiByte(w) and 1 = 1 then
SimulateKeyDown(VK_SHIFT);
{Send the VK_KEY}
SimulateKeystroke(LoByte(w), 0);
{If the key required the shift key down - release it}
if HiByte(w) and 1 = 1 then
SimulateKeyUp(VK_SHIFT);
end;
end;
{if the caps lock key was on at start, turn it back on}
if flag then
SimulateKeystroke(VK_CAPITAL, 0);
end;procedure TForm1.SaveHTMLSourceToFile(const FileName: string;
WB: TWebBrowser);
var
PersistStream: IPersistStreamInit;
FileStream: TFileStream;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
FileStream := TFileStream.Create(FileName, fmCreate);
try
Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
if FAILED(SaveResult) then
MessageBox(Handle, 'Fail to save HTML source', 'Error', 0);
finally
{ we are passing soReference in TStreamAdapter constructor,
it is our responsibility to destroy the TFileStream object. }
FileStream.Free;
end;
end; procedure TForm1.Button1Click(Sender: TObject);
begin
if SaveDialog1.Execute then
SaveHTMLSourceToFile(SaveDialog1.FileName, WebBrowser1);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
webbrowser1.Navigate('www.csdn.net');
end;procedure TForm1.Button3Click(Sender: TObject);
var
Vin,Vout : OleVariant;
savepath, keysequence: string;
begin
vin:='aaaaa.mht';
vout:='';
// WebBrowser1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DODEFAULT,vin, vout);
// WebBrowser1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_DONTPROMPTUSER,vin, vout); savepath:='c:\tmp\';
keysequence:=Format('%s%s',[savepath, FormatDateTime('yymmddmmss',now)+'.mht']);
sendkeys(keysequence);
SimulateKeyStroke(VK_TAB,0);
SimulateKeyStroke(VK_DOWN,0);
SimulateKeyStroke(VK_DOWN,0);
simulateKeyStroke(VK_RETURN,0);
SimulateKeyStroke(VK_RETURN,0);
WebBrowser1.ExecWB(OLECMDID_SAVEAS,OLECMDEXECOPT_PROMPTUSER);
end;end.
谢谢你的回复,基本上可以完成我的要求。
如果没有更好的答案,我将把分送你。还有没有更好的答案!
有次我在家里保存了mht文件拷到其它地方看,图片就没显示出来
你直接问软件的作者吧,他可金山公司开发wps的哟!