Hi, very interesting problem !
I spent almost two hours testing different approaches and ...
Delphi-Quellcode:
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.CreateForm(TformMain, formMain);
Application.Run;
end.
hier irgendwo?
Alas, this is not possible !
One approach i tested is to add a
DLL that will change set the PATH variable with SetEnvironmentVariable, the
DLL worked fine right after loading by the
OS, but ... it seems the
OS loads few DLLs in bulk then after that start to call them, if it hit missed one it will stop and unload the loaded ones, so that
DLL was loaded but no called, i mean DllMain not called.
Also patched the binary to make sure it is the first to be in the Import Table, and yes the
OS tried and loaded it first but didn't call DllMain, even it loaded few more
DLL, non being executed, so this was not a solution.
Zitat:
Oder in das initialization einer eigenen
unit, die ich dann als erstes einbinde?
Same as above, this will not help at all, as Runtime packages imported by the Import Table as declared in the
PE header, meaning, nothing will execute from the EXE Project, before all the imported libraries loaded (attached) and then all the thunk table resolved.
There is few ways to do this, but all are ugly !!
1) Use batch file to execute your EXE, with :
Zitat:
set PATH=YOUR_PACKAGE_PATH;%PATH%
//like
set PATH=D:\Program Files (x86)\Embarcadero\Studio\16.0\bin;%PATH%
2) Add another small, minimum (bare exe) to load your application but before calling CreateProcess do the same with PATH variable in the environment, in this case use SetEnvironmentVariable
https://learn.microsoft.com/en-us/wi...onmentvariable
Also here i am not sure if the the same PATH value will work, i mean passing this "
YOUR_PACKAGE_PATH;%PATH%" to SetEnvironmentVariable, so to be on the safe side i would read PATH value first with GetEnvironmentVariable, then append the path then call SetEnvironmentVariable, this before CreateProcess (or any other executing calls that works)
3) Move your EXE to the same
package directory, and leave a shortcut !!
Hope that helps, or may be someone else might have ideas to entertain.