当前位置:主页>仓库管理软件> 列表

word 调用的问题 找管家婆软件怎么使用

库存管理软件版1楼: 请大家指点迷津,我在程序中想调用word编辑功能,
我用的WordApplication
启动是
WordApplication1.Connect;
WordApplication1.Visible:= True;

这样做,确实可以了,但是当把word 关闭,再次启动是就出错了
RPC服务器不可用,请大家指点指点该怎么处理

2楼: 把任务管理器里的word进程杀掉就不会了 如管家婆软件怎么使用

3楼: dssj 你说的我感觉应该是对的, 但是还要请教在程序中如何来结束word进程呢,谢谢你的指点

4楼: WordApplication1.Connect;
WordApplication1.Visible:= True;
//TODO
WordApplication1.DisConnect;

5楼: Supermay 你的方法可以,给你加分了

6楼: Supermay 不过还要请教一下,如何来判断wordApplication是连接的,
我是这样想的
procedure TForm1.Button1Click(Sender: TObject);
begin
if WordApplication1是连接 then
WordApplication1.DisConnect
else
begin
WordApplication1.Connect;
WordApplication1.Visible:= True;
end;
end;

库存管理软件版7楼: 问题解决了给你们加分

8楼: 这个就是杀掉系统中的进程而已,论坛里有好多,我这里贴一个给你:



unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, TLHelp32, Controls, Forms, Dialogs,
StdCtrls;

type
TProcessInfo = record
ExeFile: string;
ProcessId: DWORD;
end;
ProcessInfo = ^TProcessInfo;
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure ProcessList(var pList: TList);
procedure My_RunFileScan(ListboxRunFile: TListBox);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
Current: TList;
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ProcessList(var pList: TList);
var
p: ProcessInfo;
ok: Bool;
ProcessListHandle: THandle;
ProcessStruct: TProcessEntry32;
begin
PList := TList.Create;
PList.Clear;
ProcessListHandle := CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS, 0);

ProcessStruct.dwSize := Sizeof(ProcessStruct);
ok := Process32First(ProcessListHandle, ProcessStruct);
while Integer(ok) <> 0 do
begin
new(p);
p.ExeFile := ProcessStruct.szExeFile;
p.ProcessID := ProcessStruct.th32ProcessID;
PList.Add(p);
ok := Process32Next(ProcessListHandle, ProcessStruct);
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
h: THandle;
a: DWORD;
p: PRocessInfo;
begin
if ListBox1.ItemIndex >= 0 then
begin
p := Current.Items[ListBox1.ItemIndex];
h := openProcess(Process_All_Access, true, p.ProcessID);
GetExitCodeProcess(h, a);

if Integer(TerminateProcess(h, a)) <> 0 then
begin
My_RunFileScan(ListBox1);
end;
end
else
Application.MessageBox(''请先选择一个进程!'', ''黑洞'', MB_ICONERROR + MB_OK);
end;

procedure TForm1.My_RunFileScan(ListboxRunFile: TListBox);
var
i: Integer;
p: PRocessInfo;
begin
current := TList.Create;
Current.Clear;
ListboxRunFile.Clear;
ProcessList(Current);
for i := 0 to Current.Count - 1 do
begin
new(p);
p := Current.Items[i];
ListboxRunFile.Items.Add(p.ExeFile);
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
My_RunFileScan(ListBox1);
end;

end.

9楼: 接受答案了.