Delphi 7, Add a dll to application directory on dropping a component
custom-component, delphi, delphi-2006
Solution
This idea is not going to work, in general. You are assuming that the developer will always drop your component onto a form. But they could just as well check an existing project out from revision control and then the DLL would not be created.
In my opinion you should simply document the dependency and let the developer ensure that the dependency is met. Suggest that they add the DLL to their revision control system so that it is checked out into the application directory.
The developer is going to need to be aware of this dependency when it comes to deployment. That has to be the developer's responsibility. So it is just cleaner and easier to let the developer manage this full stop.
Problem
i am developing a a component in `delphi 7` and `delphi 2006`,component uses a `.pas` (Not mine )file which requires a `DLL` file to be present in the application directory. It is possible to embed the `DLL` file into the component, so that when the user drops it on the form or create it at run time the `DLL` will be placed in the application directory? currently 1) i am telling the user to place `DLL` file in the application directory. 2) Add the `DLL` file in the Resources , so that on create, i can drop the `DLL` into the application directory? from delphidabbler_embed_resource. This i have done using ``` {Drop the Resource..!!!} procedure DropDllToApplicationDirectOry(applicationPath : string); var RS: TResourceStream; begin // Create resource stream RS := TResourceStream.CreateFromID(HInstance, 100, RT_RCDATA); try // applicationPath : example c:\MyTestProject Lee\ if DirectoryExists(applicationPath) then RS.SaveToFile(applicationPath+'myDllFileWhichIsNeeded.dll') finally // Free the stream RS.Free; end; end; ``` this `DropDllToApplicationDirectOry` take the resource from the `{$RmyDllFileWhichIsNeeded.dll.RES}` and drope to the location but how do i call `DropDllToApplicationDirectOry` this when i drop the component on the Form? i tried `initialization` of the component but DLL is not copied so i get the error EDIT For `RXControls`'s `TRxClock` when we drop the clock runs on this form, the clock begins to run(show the curent time)... so i tried this ``` constructor Tmycomponeny.Create(AOwner: TComponent); begin inherited Create(AOwner); {add dll} DropDllToApplicationDirectOry(ExtractFilePath(Application.ExeName)); end; ``` But this doesnt work.. The code OF `RXControls` ``` constructor TRxClock.Create(AOwner: TComponent); begin inherited Create(AOwner); if not Registered then begin ClockInit; Registered := True; end; Caption := TimeToStr(Time); ControlStyle := ControlStyle - [csSetCaption] {$IFDEF WIN32} - [csReplicatable] {$ENDIF}; BevelInner := bvLowered; BevelOuter := bvRaised; FTimer := TRxTimer.Create(Self); FTimer.Interval := 450; { every second } FTimer.OnTimer := TimerExpired; FDotsColor := clTeal; FShowSeconds := True; FLeadingZero := True; GetTime(FDisplayTime); if FDisplayTime.Hour >= 12 then Dec(FDisplayTime.Hour, 12); FAlarmWait := True; FAlarm := EncodeTime(0, 0, 0, 0); end; ```