delphistompclient
delphistompclient copied to clipboard
TMVCController in DLL
Hi.
How to use the TMVCController class in DLL?
In DLL `... TAdminCntrl = class(TMVCController)
end;
function getController(const AMVC: TMVCEngine): TMVCControllerClass; stdcall;
exports getController;
implementation
uses SysUtils, MVCFramework.Session, System.JSON;
function getController(const AMVC: TMVCEngine): TMVCControllerClass; stdcall; begin MVC := AMVC; Result := TAdminCntrl; end; ...`
In AppServer
... APath := GetDirectoryName(APath); Res := System.SysUtils.FindFirst(APath + '*.dll', faAnyFile, SR); try while Res = 0 do begin dll := LoadLibrary(PWideChar(APath + SR.Name)); if dll <> 0 then begin get_func := GetProcAddress(dll, 'getController'); FMVC.AddController(get_func(FMVC)); end; Res := FindNext(SR); end; finally System.SysUtils.FindClose(SR); end; ...
When you call this controller's method, the error "Invalid class typecast".
Thanks.