delphi中打印文件(200分)

  • 主题发起人 主题发起人 anndie
  • 开始时间 开始时间
A

anndie

Unregistered / Unconfirmed
GUEST, unregistred user!
程序中要实现这样一个函数,PrintAttachFile(file_path:String)
file_path是本地文件路径,文件可能是.doc,.xsl,.txt,bmp,jpg等,输入file_path,打印机直接打印,不希望有应用程序弹出(如word、excel等)。
各位,有什么好的方法?请指教,俺的200分全部奉送。
我的QQ:19176572,暗号:delphi
 
急切求教,各位兄弟指导一下方向。。。
 
再杀死word/excel进程就行
 
procedure TMainForm.killme(filename:string);
var
FSnapshotHandle:THandle;
FProcessEntry32:TProcessEntry32;
Ret:BOOL;
ProcessHndle:THandle;
ProcessID:integer;
temp:string;
flag:hwnd;
begin
FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
Ret:=Process32First(FSnapshotHandle,FProcessEntry32);
ProcessID:=FProcessEntry32.th32ProcessID;
while Retdo
begin
temp:=ExtractFileName(FProcessEntry32.szExeFile);
if temp=filename then
begin
flag:=openprocess(process_terminate,false,FProcessEntry32.th32ProcessID);
terminateprocess(flag,0);
end;
Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
ProcessHndle:=OpenProcess(PROCESS_VM_WRITE,false,ProcessID);
CloseHandle(ProcessHndle);
end;
 
如果用户本来自己就打开了word或excel,在程序杀掉word进程,会不会误杀?
另外,怎样调用word和excel打印一个文档?用createOleObject启动word或excel后,用什么方法打印?
 
1.函数有参数,不会误杀
2.ole控件有自带print方法可使用,非常方便
 
帮顶!
╭=========================================╮
80G海量源代码,控件,书籍全免费狂下不停!
http://www.source520.com

╰=========================================╯
 
多人接受答案了。
 
后退
顶部