RegisterFlashWindowClassEx
Syntax
BOOL WINAPI RegisterFlashWindowClassEx(
LPVOID lpFlashOCXCodeData,
DWORD dwSizeOfFlashOCXCode
);
Description
The RegisterFlashWindowClassEx
function registers the Flash ActiveX window class using the raw Flash OCX code provided in memory.
Unlike the traditional approach, this method does not require swflash.ocx / flash.ocx to be installed and registered on the system. This makes it possible to run Flash-enabled applications even on systems without Flash ActiveX installed, which is common after Adobe Flash Player reached End-of-Life (EOL) in December 2020.
The function allows embedding the Flash OCX code inside application resources or loading it from an external file, and then registering the control class directly at runtime. This simplifies deployment and avoids permission issues related to COM registration.
Example — Load from File
#include "f_in_box.h"
HANDLE hFile = CreateFile(_T("flash.ocx"),
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
DWORD dwFlashOCXCodeSize = GetFileSize(hFile, NULL);
HANDLE hFileMapping = CreateFileMapping(hFile,
NULL,
PAGE_READONLY,
0,
dwFlashOCXCodeSize,
NULL);
LPVOID lpFlashOCXCodeData = MapViewOfFile(hFileMapping, FILE_MAP_READ, 0, 0, 0);
if (!RegisterFlashWindowClassEx(lpFlashOCXCodeData, dwFlashOCXCodeSize))
{
// Error handling
}
UnmapViewOfFile(lpFlashOCXCodeData);
CloseHandle(hFileMapping);
CloseHandle(hFile);
Example — Load from Resource
#include "f_in_box.h"
HMODULE hModule = GetModuleHandle(NULL);
HRSRC hResInfo = FindResource(hModule, _T("FLASHOCXCODE"), _T("BIN"));
HGLOBAL hResData = LoadResource(hModule, hResInfo);
LPVOID lpFlashOCXCodeData = LockResource(hResData);
DWORD dwFlashOCXCodeSize = SizeofResource(hModule, hResInfo);
if (!RegisterFlashWindowClassEx(lpFlashOCXCodeData, dwFlashOCXCodeSize))
{
// Error handling
return;
}