TRPTJOB __stdcall rptOpenReportA(TRPT Engine, const char* Path);
TRPTJOB __stdcall rptOpenReportMem(TRPT Engine, void* Buf, int32_t Len);
BOOL32 __stdcall rptCloseReport(TRPTJOB Job);
function rptOpenReportA(const Engine: TRPT; const Path: PAnsiChar): TRPTJOB; stdcall;
function rptOpenReportMem(const Engine: TRPT; Buf: Pointer; Len: Integer): TRPTJOB; stdcall;
function rptCloseReport(const Job: TRPTJOB): LongBool; stdcall;
Purpose. Load a report definition — from a file path or an in-memory buffer — compiling it into a real, ready-to-render job handle. Both .lrpt (XML source) and .lrpc (pre-compiled container) formats are accepted transparently.
Description. Both loaders funnel into the same OpenReportCore, which sniffs the content itself — Copy(Blob, 1, 4) = 'LRPC' selects RptCompileFromBlob (the pre-compiled path, presumably faster/no XML parse); anything else is compiled fresh from XML via RptCompileFromXml. There is no file-extension check at all — a .lrpt-named file containing an LRPC magic header would load via the compiled path, and vice versa. rptOpenReportA/W additionally locate the file (LoadFileRaw, real FileExists + TFileStream read) and, on success, pass the file's own directory as BaseDir to the compiled job (Job.SetBaseDir) — used to resolve any relative asset references (images, sub-reports) inside the report definition; rptOpenReportMem has no such base directory (relative asset paths in a memory-loaded report would need to be absolute or otherwise resolvable). Both paths call Eng.RuntimeVerify — a report cannot be opened against an engine whose license has since become invalid, even if engine creation itself originally succeeded. rptCloseReport is a plain real handle-unregister-and-free.
Parameters.
| Parameter | Description |
|---|---|
Engine | A valid, currently-license-verified engine handle. |
Path | File path; format (.lrpt/.lrpc) is auto-detected from content, not the extension. |
Buf, Len | *(Mem only)* In-memory report bytes; no base directory is set for relative asset resolution. |
Job | *(CloseReport only)* The job handle to free. |
Return value. rptOpenReport(Mem): a new job handle; nil on any failure (engine invalid/unlicensed, file not found, compile error — retrieve details via rptGetLastError, which the engine's error sink is populated with on a compile exception). rptCloseReport: True if Job resolves.
C# (P/Invoke)
public static extern IntPtr rptOpenReportW(IntPtr Engine, [MarshalAs(UnmanagedType.LPWStr)] string Path);
public static extern IntPtr rptOpenReport(IntPtr Engine, [MarshalAs(UnmanagedType.LPStr)] string Path);
public static extern IntPtr rptOpenReportA(IntPtr Engine, [MarshalAs(UnmanagedType.LPStr)] string Path);
Reporting
rptOpenReportW
rptOpenReport
rptOpenReportA
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.