急着完成一个程序
用的是sql server
需要把文件(txt word pdf)放在客户端
服务器端点击文件后,可以直接打开客户端的这些文件
由于我是新手,而且关于ole的资料不多,
请高手们给点意见,相关文档,如果有关于这方面的具体程序更好
先谢谢大家了,包括来看贴的
用的是sql server
需要把文件(txt word pdf)放在客户端
服务器端点击文件后,可以直接打开客户端的这些文件
由于我是新手,而且关于ole的资料不多,
请高手们给点意见,相关文档,如果有关于这方面的具体程序更好
先谢谢大家了,包括来看贴的
// 不管是WORD,EXCLE,还中JPG的都能用
// 注意打开文件时一定要先定位(即要先写sql 查询确定有个再打开 ),要不然会出错,还有就是临时文件的删除。。
// delphi 7+sql2000通过。。unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, shellapi,Buttons, OleCtnrs;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
ADOQuery1: TADOQuery;
OleContainer1: TOleContainer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
s:string;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
if not ADOQuery1.Active then ADOQuery1.Open;
ADOQuery1.Append;
s :=ExtractFileName(OpenDialog1.FileName);
(ADOQuery1.FieldByName('doc') as TBlobField).LoadFromFile(OpenDialog1.filename);
ADOQuery1.Post;end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
(ADOQuery1.FieldByName('doc') as TBlobField).savetoFile(ExtractFileDir(Application.ExeName)+'\'+s);// (ADOQuery1.FieldByName('doc') as TBlobField).savetoFile('你要的路径' +s) ;
shellexecute(handle,nil,pchar(s),nil,nil,sw_shownormal);
end;end.
// 不管是WORD,EXCLE,还中JPG的都能用
// 注意打开文件时一定要先定位(即要先写sql 查询确定有个再打开 ),要不然会出错,还有就是临时文件的删除。。
// delphi 7+sql2000通过。。unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, StdCtrls, shellapi,Buttons, OleCtnrs;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
Button1: TButton;
Button2: TButton;
OpenDialog1: TOpenDialog;
ADOQuery1: TADOQuery;
OleContainer1: TOleContainer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
s:string;
implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute then
begin
if not ADOQuery1.Active then ADOQuery1.Open;
ADOQuery1.Append;
s :=ExtractFileName(OpenDialog1.FileName);
(ADOQuery1.FieldByName('doc') as TBlobField).LoadFromFile(OpenDialog1.filename);
ADOQuery1.Post;end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
(ADOQuery1.FieldByName('doc') as TBlobField).savetoFile(ExtractFileDir(Application.ExeName)+'\'+s); olecontainer1.CreateObjectFromFile(ExtractFileDir(Application.ExeName)+'\'+s,false);
olecontainer1.DoVerb(1);// shellexecute(handle,nil,pchar(s),nil,nil,sw_shownormal);
end;end.