As an alternative, you can use the tregsvr command from the command line or run the regsvr32.exe from the operating system.(delphi帮助中粘的-->activeX-->Registering an ActiveX control)
哈哈,我搞错了,看错! 你可以使用程序进行注册,先你可以在你的exe包含这个ocx的resource file。 选取出需要的文件registe它; 至于你如何将*.ocx包含到你的程序中,你可以这样做: 创建一个*.txt,里面是: Flash RCDATA "SWFLASH.OCX"//这里是你的*.ocx *.txt命名为*.rc如:FlashOCX.rc 进入dos执行: Br32 [path]\FlashOcx.rc//[path]为你的路径 如:brcc32 c:\Windows\system\FalseOcx.rc 这样它就可以生成一个res文件:*.res 然后再工程文件中: {$R FLASHOCX.RES}//写入你的 ... try Application.CreateForm(TForm1, Form1); except On EOleSysError Do begin Application.MessageBox('不能打开flash对象,你注册*.OCX?','Open Error',0) //开始注册你的ocx end; end; Application.Run; 以下是程序注册falshOCx.rs的代码: ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA); try FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX', fmCreate); try FileStream.CopyFrom(ResStream, 0); finally FileStream.Free; end; finally ResStream.Free; end; try {Register the OCX File} aHandle := LoadLibrary( PChar( fSystemDir+'SWFLASH.OCX' ) ); if ( aHandle >= 32 ) then begin aFunc := GetProcAddress( aHandle, 'DllRegisterServer' ); if ( Assigned( aFunc ) = TRUE ) then begin GetShortPathName( PChar( fSystemDir+'SWFLASH.OCX' ), aShortPath, 2047 ); aCommand := Format( '%s egsvr32.exe /s %s', [fSystemDir, aShortPath] ); WinExecAndWait32( aCommand, SW_HIDE ); end; FreeLibrary( aHandle ); end; //Try Creating the Form Again try Application.CreateForm(TForm1, Form1); except ShowMessage('Unable to find Macromedia Shockwave Flash.'); end; except ShowMessage('Unable to register Macromedia Shockwave Flash.'); end; {End of Registering the OCX File} end;
你可以使用程序进行注册,先你可以在你的exe包含这个ocx的resource file。
选取出需要的文件registe它;
至于你如何将*.ocx包含到你的程序中,你可以这样做:
创建一个*.txt,里面是:
Flash RCDATA "SWFLASH.OCX"//这里是你的*.ocx
*.txt命名为*.rc如:FlashOCX.rc
进入dos执行:
Br32 [path]\FlashOcx.rc//[path]为你的路径
如:brcc32 c:\Windows\system\FalseOcx.rc
这样它就可以生成一个res文件:*.res
然后再工程文件中:
{$R FLASHOCX.RES}//写入你的
...
try
Application.CreateForm(TForm1, Form1);
except
On EOleSysError Do
begin
Application.MessageBox('不能打开flash对象,你注册*.OCX?','Open Error',0)
//开始注册你的ocx
end;
end;
Application.Run;
以下是程序注册falshOCx.rs的代码:
ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA);
try
FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX', fmCreate);
try
FileStream.CopyFrom(ResStream, 0);
finally
FileStream.Free;
end;
finally
ResStream.Free;
end; try
{Register the OCX File}
aHandle := LoadLibrary( PChar( fSystemDir+'SWFLASH.OCX' ) );
if ( aHandle >= 32 ) then
begin
aFunc := GetProcAddress( aHandle, 'DllRegisterServer' );
if ( Assigned( aFunc ) = TRUE ) then
begin
GetShortPathName( PChar( fSystemDir+'SWFLASH.OCX' ), aShortPath, 2047 );
aCommand := Format( '%s
egsvr32.exe /s %s', [fSystemDir, aShortPath] );
WinExecAndWait32( aCommand, SW_HIDE );
end;
FreeLibrary( aHandle );
end; //Try Creating the Form Again
try
Application.CreateForm(TForm1, Form1);
except
ShowMessage('Unable to find Macromedia Shockwave Flash.');
end; except
ShowMessage('Unable to register Macromedia Shockwave Flash.');
end;
{End of Registering the OCX File}
end;