HKEY_LOCALMACHINE ...运行-应用程序已启动,但不执行任何操作,仅停留在暂停状态 [英] HKEY_LOCALMACHINE...Run - App gets started, but does nothing, simply stays as if paused

查看:111
本文介绍了HKEY_LOCALMACHINE ...运行-应用程序已启动,但不执行任何操作,仅停留在暂停状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我遇到一个应用程序问题,该应用程序在用户运行时可以正常运行,但是从"HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Run"运行时却无法正常工作.
您可以在任务管理器"中看到该应用程序不执行任何操作.该应用程序没有任何关联的窗体或窗口,但是正如我之前说的,如果用户手动运行它,则可以正常运行.
我尝试制作一个小测试应用程序.令人惊讶的是,我遇到了同样的问题.仅在您手动启动应用程序时有效.请参见以下内容:

Hello,
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:

program Test;
uses Windows, SysUtils;
{$R *.RES}
var
  aux: integer;
  hf: THandle;
  t: string;
  written: Cardinal;
begin
  hf := CreateFile(''TestLog.txt'', GENERIC_WRITE, 0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
  try
    //so, you can see the process during 1 minute in "Task manager"
    for aux := 1 to 60 do begin
      Sleep(1000); 
      t := DateTimeToStr(Now) + #13#10;
      WriteFile(hf, t[1], Length(t), written, nil);
    end;
  finally
    CloseHandle(hf);
  end;
end.




如果编译并将条目添加到Windows注册表中,则可以检查它是否正在运行,并在任务管理器"中显示大约1分钟并死掉.但是没有文件写入磁盘.
相反,如果您手动运行该应用程序,它将完美地写入文件.
我测试了通过另一个带有表单的虚拟应用程序更改"exe"文件的方法,它可以正常工作!!!也尝试过搬到HKCU,但也没有成功.

对发生的事情有任何想法吗?

预先感谢,
VictorVG




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,
VictorVG

推荐答案

R * .RES} 变种 aux:整数; hf:THandle; t:字符串; 书面:红衣主教; 开始 hf:= CreateFile(''TestLog.txt'',GENERIC_WRITE,0,nil,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0); 尝试 //因此,您可以在任务管理器"中1分钟内看到该过程 对于aux:= 1到60开始 睡眠(1000); t:= DateTimeToStr(Now)+#13#10; WriteFile(hf,t [1],Length(t),写入,nil); 结尾; 最后 CloseHandle(hf); 结尾; 结束.
R *.RES} var aux: integer; hf: THandle; t: string; written: Cardinal; begin hf := CreateFile(''TestLog.txt'', GENERIC_WRITE, 0, nil, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0); try //so, you can see the process during 1 minute in "Task manager" for aux := 1 to 60 do begin Sleep(1000); t := DateTimeToStr(Now) + #13#10; WriteFile(hf, t[1], Length(t), written, nil); end; finally CloseHandle(hf); end; end.




如果编译并将条目添加到Windows注册表中,则可以检查它是否运行,并在任务管理器"中显示大约1分钟并死掉.但是没有文件写入磁盘.
相反,如果您手动运行该应用程序,它将完美地写入文件.
我测试了通过另一个带有表单的虚拟应用程序更改"exe"文件的方法,它可以正常工作!!!也尝试过搬到HKCU,但也没有成功.

对发生的事情有任何想法吗?

预先感谢,
VictorVG




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,
VictorVG


问题已解决!
它就在路上.我没有指定完整路径.
因此,当我双击该exe来运行该应用程序时,由于工作目录与该应用程序相同,因此无需使用完整路径.但是,从注册表运行时,工作路径变为"C:\ Documents and Settings \ User \ Application Data \ ...",因此,该应用程序正在运行并写入此文件夹.
我已经测试了我的应用程序,为所有文件指定了完整路径,并且工作正常!!!


感谢DelphiPages的mdixon7610,
VictorVG
Problem fixed!!
It was just around the path. I am not specifying the full path.
So, when I run the app double-clicking the exe, I don''t need to use full path, as the working directory is the same than the app. But, when run from the registry the working path becomes "C:\Documents and Settings\User\Application Data\...", so, the app is running and writting to this folder.
I have tested my app specifying the full path for all the files and it works fine!!!


Thanks to mdixon7610 from DelphiPages,
VictorVG


这篇关于HKEY_LOCALMACHINE ...运行-应用程序已启动,但不执行任何操作,仅停留在暂停状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆