GetModuleFileName和区分大小写 [英] GetModuleFileName and case sensitivity

查看:135
本文介绍了GetModuleFileName和区分大小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在我的程序中使用GetModuleFileName API。它返回我的可执行文件的名称。但是,我看到在不同的环境下,它给我输出像



- Win XP

输出:test.exe

- 赢7

输出:TEST.EXE



不确定为什么API给了我不同的输出。请帮忙。

Hi Guys,
I am using GetModuleFileName API in my program. It returns me the name of my executable. However, I see that under different environments, it give me output like

-- Win XP
output: test.exe
-- Win 7
output: TEST.EXE

not sure why the API gives me different outputs. Please help.

推荐答案

来自 GetModuleFileName() [ ^ ]:
Quote:

字符串返回将使用加载模块时指定的相同格式。因此,路径可以是长文件名或短文件名,并且可以使用前缀\\?\。

The string returned will use the same format that was specified when the module was loaded. Therefore, the path can be a long or short file name, and can use the prefix "\\?\".

因此,当在资源管理器中双击文件时,它应该像在磁盘上一样在使用命令shell启动程序时键入。



另一个引用:

So it should be like on your disk when double clicking the file in the Explorer and as typed when using the command shell to start the program.

Another cite:

引用:

如果DLL在两个进程中加载​​,则其在一个进程中的文件名可能与其他进程中的文件名不同。

If a DLL is loaded in two processes, its file name in one process may differ in case from its file name in the other process.

虽然这适用于DLL,但它表示情况并不总是相同。



所以你应该接受这个行为,并且可以选择使用 FindFirstFile()从磁盘中获取真实姓名。

While this applies to DLL's it indicates that the case it not always the same.

So you should accept the behaviour and optionally get the real name from the disk using FindFirstFile().


您已经在 http://上发布了此问题www.codeproject.com/Messages/4619610/GetModuleFileName-and-case-sensitivity.aspx [ ^ ],并收到一些反馈。请仅在一个论坛发帖。
You already posted this question at http://www.codeproject.com/Messages/4619610/GetModuleFileName-and-case-sensitivity.aspx[^], and received some feedback. Please post in one forum only.


这篇关于GetModuleFileName和区分大小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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