自动启动和当前目录 [英] Autostart and CurrentDirectory

查看:24
本文介绍了自动启动和当前目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对WindowsAPI函数很困惑

I am very confused about the WindowsAPI function

获取当前目录

当我的应用程序从自动启动 (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run) 启动时,当前目录总是:%windir%\system32

When my application get's started from the autostart (HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run) the current directory is ALWAYS : %windir%\system32

这是为什么?

推荐答案

正如预期的那样.默认情况下,应用程序从父进程继承当前目录,大多数系统组件使用 system32 作为当前目录.

That's as expected. By default, applications inherit the current directory from the parent process, and most system components use system32 as the current directory.

当您通过双击启动应用程序时,资源管理器会遇到明确设置当前目录的麻烦.当从 Run 键启动应用程序时,它不会.可能没有特别的原因,只是编写处理 Run 键的代码的程序员要么没有考虑,要么认为不值得付出努力.

When you launch an application by double-clicking, Explorer goes to the trouble of explicitly setting the current directory. When an application is launched from the Run key, it doesn't. There's probably no particular reason why not, just that the programmers who wrote the code for processing the Run key either didn't think about it or didn't think it was worth the effort.

这篇关于自动启动和当前目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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