如何在Windows PE中运行C ++可执行文件? [英] How to run C++ executable in Windows PE?

查看:342
本文介绍了如何在Windows PE中运行C ++可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用CLI控制台应用程序和Visual Basic 2010制作的可执行文件。我可以从开发人员机器上完全正常地运行该程序。

I have an executable I made using a CLI console application with Visual Basic 2010. I can run the program completely fine from my developer machine.

但是,当我将可执行文件复制到另一台计算机上,重新引导到预安装环境,然后再次运行该可执行文件,完全没有任何反应。没有显示任何错误或任何错误。

However, when I copy the executable over to another machine, re-boot to a pre-installation environment and run the executable again, nothing happens at all. There are no errors shown or anything.

我的猜测是,在没有此环境未加载的某些依赖项的情况下,可执行文件无法运行,但我需要它能够正常工作

My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.

有什么想法吗?

推荐答案

首先,由于该问题被标记为 c ++,并且您多次提及C ++ / CLI,因此我认为 Visual Basic 2010是 Visual Studio 2010的错字。但是无论采用哪种方式,无论您是使用Visual Basic(VB.NET)还是C ++ / CLI编写应用程序,问题都完全相同。

First of all, since the question is tagged "c++" and you mention C++/CLI several times, I assume that "Visual Basic 2010" is a typo for "Visual Studio 2010". But either way, whether you've written the application in Visual Basic (VB.NET) or C++/CLI, the problem is exactly the same.


我的猜测是,如果没有在此环境中未加载的某些依赖项,可执行文件就无法运行,但是我需要它在PE中运行。

My guess is the executable can't run without certain dependencies that aren't loaded at this environment, but I need it to work in a PE.

完全正确。您已经编写了一个针对 .NET Framework 的应用程序。与需要JVM的Java应用程序类似,.NET应用程序要求安装.NET Framework才能运行(或兼容的替代实现,例如单声道)。不幸的是,Windows PE 不支持.NET Framework

That's exactly correct. You've written an application that targets the .NET Framework. Somewhat like Java applications requiring a JVM, .NET applications require that the .NET Framework be installed in order to run (or a compatible alternative implementation, like Mono). Unfortunately, Windows PE does not support the .NET Framework.

请注意,是否编写了WinForms,WPF或控制台应用程序都无关紧要。尽管它们以非常不同的方式呈现其UI,但它们全部取决于所安装的.NET Framework。

Note that it is irrelevant whether you've written a WinForms, WPF, or Console application. Although they present their UI in very different ways, they all depend on the .NET Framework being installed.

您将需要(重新)以另一种编程语言编写应用程序,该语言可生成本机代码,而无需依赖.NET Framework。 C和C ++是流行的选择。如果选择使用C ++,请确保创建Visual Studio称为 Win32项目的项目。这是直接针对底层操作系统API(即本机应用程序)的对象,并且不依赖于.NET Framework。远离描述中带有 .NET或 CLR的任何内容。

You will need to (re-)write the application in a different programming language, one that generates native code without any dependencies on the .NET Framework. C and C++ are popular choices. If you choose to use C++, make sure that you create what Visual Studio calls a "Win32" project. This is one that targets the underlying operating system APIs directly (i.e. a native application) and does not have a dependency on the .NET Framework. Stay away from anything that has ".NET" or "CLR" in its description.


我真的不完全了解当应用程序是否使用.NET时...我只是习惯了Linux C / C ++开发。我讨厌Microsoft屎

I don't really have a full comprehension of when an application is using .NET or not... I am just used to Linux C/C++ development. I hate Microsoft shit

只要在代码中使用.NET Framework库/类,它都会使用.NET。我不太确定为什么这么难理解。如果您使用的第三方库由于某些原因在某些环境中不可用,则在Linux上很容易存在相同的问题。这不是Microsoft的问题,而是使用错误的工具完成工作的问题。 .NET Framework是围绕本机API的面向对象的包装,它使人们可以更轻松地启动和运行Windows编写的程序。但是,如果您习惯于Linux C / C ++开发,那么编写一个直接针对本机API而不使用.NET的简单控制台应用程序就应该没什么麻烦。

It uses .NET whenever you use the .NET Framework libraries/classes in your code. I'm not really sure why this is so difficult to understand. The same problem could easily exist on Linux if you were using a third-party library that was not available in certain environments for whatever reason. This is not Microsoft's problem, it's an issue of using the wrong tools for the job. The .NET Framework is an object-oriented wrapper around the native APIs that makes it much easier for people to get up and running writing programs for Windows. But if you're "used to Linux C/C++ development", you should have little trouble writing a simple console application that targets the native APIs directly without using .NET.

如果您对微软狗屎的仇恨变成一种过敏,则可以完全避免使用Visual Studio,并下载 MinGW ,这是您可能习惯的GCC编译器的Windows端口。结合您最喜欢的Windows端口Vi,您可以在与以前非常相似的环境中工作。而且,由于GCC不支持C ++ / CLI或.NET Framework,因此您不必担心选择错误的选项。

If your hatred for "Microsoft shit" has turned into an allergy, you can avoid Visual Studio entirely and download MinGW, which is a Windows port of the GCC compiler you're probably used to. Combined with your favorite Windows port of Vi, you're working in an environment very similar to the one you're used to. And since GCC doesn't support C++/CLI or the .NET Framework, you won't have to worry about getting stuck picking the wrong option.

这篇关于如何在Windows PE中运行C ++可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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