高分求教有关"Import Type Library"的问题
ysh 2003-02-18 09:28:50 tlb的类型库,用BCB的“Import Type Library”导入后,如何调用?有源代码最好!
kingcaiyao(AKing)介绍说:
用Import Type Library 导入后,会生成一个**_TLB.h,将你的这头文件加入到你的应用程序,然后用以下三种方法其中之一来调用:
1.采用自定义接口
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCOMIYourInterface App=CoYourInterface::Create();
App->YourMethodName(Parameter1,Parameter2,......);
}
2.采用IDISPATCH接口
void __fastcall TForm1::Button1Click(TObject *Sender)
{
IYourInterfaceDisp App;
App.BindDefault();
App.YourMethodName(Parameter1,......);
}
3.采用万能对象
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Variant V=Variant::CreateObject("ServerName.COM Object Name");//括号中的是COM对象的名称,你需要在注册表中找到它。
V.YourMethodName(Parameter1,....);
}