2.然后再delphi中安装:Component --> Import ActiveX Control
3.这是最大的问题就是:如何使这个ocx组件,在别的程序中使用时还可以用。
解决的方法可以这样:
你可以在你的exe包含这个ocx的resource file。选取出需要的文件register 它
有这样的例子:
1.create a txt and write:
Flash RCDATA "SWFLASH.OCX"
将它另存为以rc为后缀的文件,这里我存为:FlashOCX.rc
注意的*.rc文件必须在和swflash.ocx在同一路径下。
open 你的 Dos Windows and write Br32 Dir of File\FlashOcx.rc
就是:brcc32 c:\Windows\system\FalseOcx.rc
这样它就可以生成一个res文件:flashocx.res
这时你就可以在程序中包含使用它了。
{$R *.RES}
{$R FLASHOCX.RES}
代码:
program Project1;
uses
Forms,comobj,
Unit1 in 'Unit1.pas' {Form1};
{$R *.RES}
{$R FLASHOCX.RES}
begin
Application.Initialize;
try
Application.CreateForm(TForm1, Form1);
except
On EOleSysError Do
begin
Application.MessageBox('不能打开flash对象,你注册SWFLASH.OCX?','Open Error',0)
//Register OCX File because not found.
end;
end;
Application.Run;
end.