需要在运行时在 VC 中以编程方式获取可执行文件(正在执行的文件)的 .obj 文件名吗?

发布于 2024-08-27 12:29:48 字数 298 浏览 5 评论 0原文

假设我有一个包含多个源(.cpp)文件(例如5个)的VC++项目,它将生成5个.obj文件(对应于我的.cpp文件,而不是所有内核和操作系统层,包括.obj文件)。

我的项目包括 xyz_1.cpp、xyz_2.cpp、xyz_3.cpp、xyz_4.cpp,并将对应于 4 个各自的 .objs 文件。

如何在运行时获取这 4 个 .obj 文件的名称?在运行时我需要检查有多少个 obj 文件及其名称。

我不需要所有内核或操作系统层 .obj,我只需要我的 .cpp 的 .obj。

问候,

乌斯曼

Suppose I have a VC++ project containing number of Source (.cpp) files (e.g. 5), it will generate 5 .obj files (corresponding to my .cpp files not all kernel and OS layers including .obj files).

My project includes xyz_1.cpp, xyz_2.cpp, xyz_3.cpp, xyz_4.cpp, and will corresponds with 4 respective .objs files.

How can I get the names of these 4 .obj files at runtime? On runtime I need to check how many obj files there are and their names.

I don't need all kernel or OS layer .obj's, I only need .obj's of my .cpp's.

Regards,

Usman

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

黄昏下泛黄的笔记 2024-09-03 12:29:48

.obj 文件名不是标准的。一些编译器会创建与 .cpp 文件相对应的文件,其他编译器可能会创建具有随机名称的文件(VC 实际上在配置链接时代码生成时会这样做),而其他编译器可能会完全跳过此阶段。

所以你的问题没有明确的答案。它取决于编译器和编译标志。

此外,据我所知,没有办法获得这些信息。

The .obj file names are not standard. some compilers hay create ones that correspond to the .cpp files, others may create ones with random names (VC actually does that when configured with link time code generation) while others may skip this stage completely.

So there is no well defined answer to your question. it is compiler and compilation flags dependent.

Furthermore, there is no way to get this information that I know of.

将军与妓 2024-09-03 12:29:48

听起来你需要使用微软的 dbghelp.dll 库及其调试接口访问 SDK

It sounds like you need to use Microsoft's dbghelp.dll library and their Debug Interface Access SDK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文