BoxedApp Blog

BoxedApp: Tips'n'Tricks, Examples, Use Cases etc.

How to embed Flash Player ActiveX using BoxedApp SDK


Share this post Bookmark and Share

OK, let’s get started.

One of the most important features is embedding ActiveX into an application. BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry registers a virtual file in a virtual registry. In detail, it loads a specified file (LoadLibrary) and calls DllRegisterServer (exported from the DLL). All changes made by DllRegisterServer are saved in the virtual registry; the system registry remains unchanged.

After that, CoCreateInstance (and the related functions) will receive the correct information from the “registry”.

Embedding Flash step-by-step:

1. Get started with BoxedApp SDK:

BoxedAppSDK_Init();

2. Create a virtual file with Flash.ocx:

LPVOID pBuffer;
DWORD dwSize;

// LoadResourceHelper gets resource pointer and size
LoadResourceHelper(
   MAKEINTRESOURCE(IDR_BIN_FLASH_OCX), 
   _T("BIN"), 
   pBuffer, 
   dwSize);

HANDLE hVirtualFile1 = 
   BoxedAppSDK_CreateVirtualFile(
      _T("C:\\Flash9e.ocx"), 
      GENERIC_READ, 
      FILE_SHARE_READ, 
      NULL, 
      CREATE_NEW, 
      0, 
      NULL);  

DWORD dwTemp; 
WriteFile(hVirtualFile1, pBuffer, dwSize, &dwTemp, NULL);

CloseHandle(hVirtualFile1);

3. Register the COM library in the virtual registry:

BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry(_T("C:\\Flash9e.ocx"));

Further on, when you have created a Flash ActiveX instance, the COM subsystem (CoCreateInstance) will read information from the virtual registry and create an ActiveX object from the virtual DLL.

In particular, using this method you can create applications that are ready to work without installation (so-called “portable applications”) even if they use ActiveX or others COM-objects. Simply create a virtual file with an appropriate DLL and call BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry.


Related links:

  1. Download BoxedApp SDK samples
  2. The best solution to work with Flash ActiveX (embedding is also supported)
  3. Function BoxedAppSDK_RegisterCOMLibraryInVirtualRegistry
Share this post Bookmark and Share






Write a Comment

You must be logged in to post a comment. Log in