Load Flash ActiveX Without Installation or Registration

Using the Flash Player ActiveX control in a Delphi or C++Builder application usually requires that swflash.ocx or flash.ocx be installed and registered on the system. This can create issues if the user does not have permissions to write to system folders or to register COM components.

Since the official Adobe Flash Player End of Life (EOL) in December 2020, most modern computers no longer have Flash Player ActiveX installed by default, and its installation is not recommended. This makes applications that depend on system-wide installation of flash.ocx unreliable.

TFlashPlayerControl avoids these issues by allowing the control code to be loaded directly from any source (for example, from an application resource or from a file) without temporary files or registration. By default, the already registered Flash Player ActiveX is used, but developers can provide an alternative source if needed.

This approach simplifies deployment and ensures that applications can run even if Flash Player ActiveX is not installed on the target system.

To achieve this, use the global function FlashPlayerControl.LoadFlashOCXCodeFromStream. This is a function defined at the module level (not an instance method), and it loads the Flash ActiveX (flash.ocx) binary code directly from a TStream.


Delphi Example (Load from Resource)

{$RESOURCE 'res\flash.res'}
 
var
  FlashCodeStream: TResourceStream;
 
initialization
  FlashCodeStream := TResourceStream.Create(0, 'FlashOCXCode', 'BIN');
  FlashPlayerControl.LoadFlashOCXCodeFromStream(FlashCodeStream);
  FlashCodeStream.Free;

C++Builder Example (Load from Resource)

#pragma resource "res\\flash_ocx.res"
 
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  Application->Initialize();
 
  TResourceStream* FlashCodeStream = new TResourceStream(0, "FlashOCXCode", "BIN");
  Flashplayercontrol::LoadFlashOCXCodeFromStream(FlashCodeStream);
  delete FlashCodeStream;
}

Delphi Example (Load from File)

var
  FlashCodeStream: TFileStream;
 
initialization
  FlashCodeStream := TFileStream.Create('flash.ocx', fmOpenRead or fmShareDenyNone);
  FlashPlayerControl.LoadFlashOCXCodeFromStream(FlashCodeStream);
  FlashCodeStream.Free;

C++Builder Example (Load from File)

WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
  Application->Initialize();
 
  TFileStream* FlashCodeStream = new TFileStream("flash.ocx", fmOpenRead | fmShareDenyNone);
  Flashplayercontrol::LoadFlashOCXCodeFromStream(FlashCodeStream);
  delete FlashCodeStream;
}