freepascal 2.2 发布了, com/ole 兼容性有所提高
如下所示,IDISPATCH赋值给variant后可以调用方法(quit)。
program cp4f;
{$APPTYPE CONSOLE}
uses
SysUtils,
variants,
comobj,
activex,
windows ;
var W:variant;
m_s:boolean;
m_s2:widestring;
begin
{ TODO -oUser -cConsole Main : Insert code here }
CoInitialize(nil);
w := CreateOLEObject('Word.Application') ;
Sleep(2000);
// m_s:=w.Visible;
// writeln('Visible:',m_s);
//m_s2:=w.Version;
//writeln('version:',m_s2);
w.quit;
w:=unassigned;
CoUnInitialize;
end.
但是属性访问就没有试验成功。。似乎要用更原始的方式。。
program cp2;
{$APPTYPE CONSOLE}
uses
SysUtils,
variants,comobj,activex,ole2,windows;
var W:IDispatch;
V:String;
theid:Integer;
mv,ppn:widestring;
mres:HRESULT;
ho,VRESULT:VARIANT;
rest :boolean;
myinp:TDispParams=();
begin
CoInitialize(nil);
W:=CreateOleObject('Word.Application');
ppn:='Visible';
mres:=W.getidsofnames(
guid_null,
@ppn,
1,
locale_system_default,
@theid
);
olecheck(mres);
writeln(theid);
mres:= W.Invoke(
theid,
GUID_NULL,
locale_system_default,
DISPATCH_PROPERTYGET,
myinp,
@VRESULT,
nil,
nil
);
olecheck(mres);
rest:=VRESULT;
writeln(rest);
ho:=W;
W:=nil;
ho.quit;
ho:=unassigned;
CoUnInitialize;
end.
发表评论
- 浏览: 31040 次
- 性别:


- 详细资料
搜索本博客
最新评论
-
daedoe Form Designer 在 ...
...运行有点问题。。。。插入FORM的控件的事件无法设置了。。。
-- by zzsczz -
TinyPascal... ...
TinyPascalView.h 最后3行删除掉即可 /* #ifndef ...
-- by zzsczz -
TinyPascal... ...
这么少的代码就可以实现如此强大的功能,C++/Spirit足以令C#和Java汗 ...
-- by wdx04 -
vc6 上安装stlport和boos ...
2005bug太多,2003还是能更好一些。
-- by simohayha -
vc6 上安装stlport和boos ...
为什么不用VC 2005呢?VC 6是很老的编译器了,对模版支持也不好。
-- by bigpanda






评论排行榜