Delphi DLL Dynamic Error raise to many consecutive exception -
i found source code delphi sample codes, , adding control or component inside delphi dynamic dll, can't figure out,
library dllentrylib; uses sysutils, windows, dialogs, classes, mshtml, shdocvw; type tmyweb = class(twebbrowser) constructor create(aowner: tcomponent); override; end; var web: tmyweb; // initialize properties here constructor tmyweb.create(aowner: tcomponent); begin inherited create(self); end; procedure getweb; begin web := tmyweb.create(nil); web.navigate('http://mywebsite.com'); end; procedure xdllentrypoint(dwreason: dword); begin case dwreason of dll_process_attach: begin getweb; //i think error here, how work out? showmessage('attaching process'); end; dll_process_detach: showmessage('detaching process'); dll_thread_attach: messagebeep(0); dll_thread_detach: messagebeep(0); end; end; begin { first, assign procedure dllproc variable } dllproc := @xdllentrypoint; { invoke procedure reflect dll attaching process } xdllentrypoint(dll_process_attach); end. //in application form. procedure tmainform.btnloadlibclick(sender: tobject); begin if libhandle = 0 begin libhandle := loadlibrary('dllentrylib.dll'); if libhandle = 0 raise exception.create('unable load dll'); end else messagedlg('library loaded', mtwarning, [mbok], 0); end;
how rid of error? raise many consicutive exception
when write:
inherited create(self);
you should write
inherited create(aowner);
you asking control own itself. cannot work. quite possibly leads non-terminated recursion if constructor fails.
the other big problem creating web browser control inside dllmain
. that's big no-no. you'll want stop doing that. move code separate exported function. nothing in dllmain
.
presumably caller has initialized com. if not, need ensure caller so. if caller vcl forms app com initialized automatically.
Comments
Post a Comment