简体   繁体   English

Windows启动时调用应用程序无法正常启动

[英]Application does not start properly when called on Windows startup

I have a strange problem. 我有一个奇怪的问题。 I have an Qt application with dynamic linked DLLs. 我有一个带有动态链接DLL的Qt应用程序。

When I open the .exe file the application starts correctly, even if I open it from a desktop shortcut as soon, as I see the desktop on Windows start. 当我打开.exe文件时,即使我从桌面快捷方式打开它,应用程序也可以正确启动,因为我看到Windows上的桌面已启动。

But when I add it to the HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run it does not start correctly. 但是,当我将其添加到HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run它无法正确启动。

eg (edit) the log file is not created and the QlistView doesnt display any information (list of items) from the SQLite database, and I cannot connect to a server via QTcpSocket. 例如(未编辑),未创建日志文件,并且QlistView不显示来自SQLite数据库的任何信息(项目列表),并且我无法通过QTcpSocket连接到服务器。 (even if the autostart version starts after the manually started). (即使自动启动版本是在手动启动之后启动的)。

(edit) the log file doesn't seem to work as well. (编辑)日志文件似乎无法正常运行。

(Posted on behalf of the OP) . (代表OP张贴)

The solution was to change the current directory to the app directory by: 解决方案是通过以下方式将当前目录更改为app目录:

QDir::setCurrent(QCoreApplication::applicationDirPath());

At startup the current directory is set to windows/system32. 启动时,当前目录设置为Windows / system32。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM