W
wuzhonglinquan
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DdeMan;
type
TForm1 = class(TForm)
DdeClientConv1: TDdeClientConv;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure RunMacro(MacroChar);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
RunMacro('[FileNew]');
end;
procedure TForm1.RunMacro(Macro: PChar);
var
pMacro:array[0..80] of char;
begin
DdeClientConv1.SetLink('winWord.exe','system');
DdeClientConv1.OpenLink;
strCopy(pMacro,Macro);
//把Macro复制到pMacro,返回Pchar字符串
if Not DdeClientConv1.ExecuteMacro(pMacro,false) then
ShowMessage('Unable to Execute Macro');
DdeClientConv1.CloseLink;
end;
end.
所有代码都是看书的,编译通过了,但是就是调不出来word程序,为什么?
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DdeMan;
type
TForm1 = class(TForm)
DdeClientConv1: TDdeClientConv;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
procedure RunMacro(MacroChar);
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
RunMacro('[FileNew]');
end;
procedure TForm1.RunMacro(Macro: PChar);
var
pMacro:array[0..80] of char;
begin
DdeClientConv1.SetLink('winWord.exe','system');
DdeClientConv1.OpenLink;
strCopy(pMacro,Macro);
//把Macro复制到pMacro,返回Pchar字符串
if Not DdeClientConv1.ExecuteMacro(pMacro,false) then
ShowMessage('Unable to Execute Macro');
DdeClientConv1.CloseLink;
end;
end.
所有代码都是看书的,编译通过了,但是就是调不出来word程序,为什么?