I have a problem with an app which works fine when the user runs it, but doesn't work when run from "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run".
You can see the app in the "Task manager" doing nothing. The app doesn't have any associated form or window, but as I said before, it works fine if the user runs it manually.
I tried making a little test app. And surprisingly I get the same problem. Only works if you start the app manually. Please, see below:
uses Windows, SysUtils;
hf := CreateFile('TestLog.txt', GENERIC_WRITE, 0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
for aux := 1 to 60 do begin
t := DateTimeToStr(Now) + #13#10;
WriteFile(hf, t, Length(t), written, nil);
If you compile and add an entry to the Windows registry, you could check, that it runs, appears about 1 minute in the "Task manager" and dies. But no file was written to disk.
Instead, if you run the app manually, it writes the file perfectly.
I tested changing the "exe" file by another dummy app with a Form and it works!!! Also tried moving to HKCU, but also it didn't work.
Any idea on what is happening??
Thanks in advance,