简体   繁体   English

旧的本机应用程序可以在Windows8平板电脑上运行吗?

[英]Can old native applications run on Windows8 tablet version?

在此输入图像描述

I don't understand this picture well. 我不太了解这张照片。 In the Metro style Apps, what does C/C++ mean? 在Metro风格的应用程序中,C / C ++意味着什么? Native C/C++? 原生C / C ++? or is it managed C++? 或者它是托管C ++? They(Metro style apps) don't even have Win32 layer! 他们(Metro风格的应用程序)甚至没有Win32层!

To make an application which compatible with both Metro style and Desktop, should we only use .NET code? 要创建一个兼容Metro风格和桌面的应用程序,我们应该只使用.NET代码吗? The old native applications can run on Windows8 Tablet? 旧的本机应用程序可以在Windows8 Tablet上运行吗?

Yes old apps, including unmanaged native apps written with C/C++/Win32 and managed ones in .NET, will run on a Windows 8 tablet fine. 是旧的应用程序,包括用C / C ++ / Win32编写的非托管本机应用程序和.NET中的托管应用程序,可以在Windows 8平板电脑上运行。 Except of course if the tablet is running an ARM processor; 当然,平板电脑正在运行ARM处理器; then it will only support the new Metro-style apps (and also apps which specifically target the ARM). 然后它只支持新的Metro风格的应用程序(以及专门针对ARM的应用程序)。

In the picture, C/C++ means unmanaged native apps sitting on the WinRT API, which is also unmanaged native. 在图片中,C / C ++表示WinRT API上的非托管本机应用程序,它也是非托管本机的。 There will be seamless integration with .NET for those that want to use C# or VB.NET. 对于想要使用C#或VB.NET的用户,将与.NET无缝集成。

On your last question, you can't make an application which is compatible to both Metro-style and Desktop ... they are mutually exclusive - you have to make a choice. 在你的上一个问题上,你不能创建一个兼容Metro风格和桌面的应用程序......它们是互斥的 - 你必须做出选择。

WinRT is native code, and C/C++ are native, although their Syntax when used with WinRT looks like C++/CLI. WinRT是本机代码,C / C ++是本机代码,尽管它们与WinRT一起使用时的语法类似于C ++ / CLI。 From what I hear, it seems like an API that was designed for C++ rather than C, so it's very object oriented and people seem rather excited. 从我听到的,它似乎是一个专为C ++而不是C设计的API,所以它非常面向对象,人们似乎很兴奋。

C# will use the usual way of COM Interop to use WinRT. C#将使用通常的COM Interop方式来使用WinRT。

To quote Andy Rich (MSFT) from this discussion : 引用Andy Rich(MSFT)的讨论

Core WinRT is NOT managed - it is native and COM-based. 核心WinRT不受管理 - 它是原生的和基于COM的。 Our language provides a fully-native projection of that in a high-level syntax, but you aren't tied to that syntax - you will be able to target the Windows Runtime using low-level COM or WRL (an ATL-like template library) as well. 我们的语言在高级语法中提供完全原生的投影,但您不依赖于该语法 - 您将能够使用低级COM或WRL(类似ATL的模板库)来定位Windows运行时)以及。 (The C#/VB projection is a different story, they generate runtime-callable wrapper objects which marshal between .NET and WinRT.) (C#/ VB投影是一个不同的故事,它们生成运行时可调用的包装器对象,它们在.NET和WinRT之间编组。)

C++ in Metro apps is native C++. Metro应用程序中的C ++是本机C ++。 It is recommended that you use the new language extensions , which look a lot like C++/CLI, and provide a similarly high-level experience - eg no need to manually deal with reference counting objects and strings, or implementing and calling QueryInterface - but in pure native code. 建议您使用新的语言扩展 ,它看起来很像C ++ / CLI,并提供类似的高级体验 - 例如,无需手动处理引用计数对象和字符串,或实现和调用QueryInterface - 但是纯本机代码。 You don't have to do that, though. 但是,您不必这样做。

In any case, for your own classes, you can define them in vanilla C++, and compile them to a library. 在任何情况下,对于您自己的类,您可以在vanilla C ++中定义它们,并将它们编译到库中。 This way, you can share your logic between the desktop version of your app (with UI implemented using MFC, Win32, Qt or whatever) and the Metro version (with UI implemented using WinRT APIs). 这样,您可以在应用程序的桌面版本(使用MFC,Win32,Qt或其他任何方式实现UI)和Metro版本(使用WinRT API实现UI)之间共享逻辑。 Similarly, for .NET apps, you can separate logic into a class library that's reused between desktop and Metro. 同样,对于.NET应用程序,您可以将逻辑分离为在桌面和Metro之间重用的类库。

There's no way to write a single app that will run on both with the same UI layer, neither in C++ nor in .NET. 没有办法编写一个可以在同一个UI层上运行的应用程序,无论是在C ++还是在.NET中。 On the other hand, you can approximate that to some extent with HTML/JS, if you avoid using WinRT APIs and stick to HTML5 standard - then you can make a "desktop version" by hosting it in a browser. 另一方面,如果您避免使用WinRT API并坚持使用HTML5标准,您可以在某种程度上使用HTML / JS进行近似 - 那么您可以通过在浏览器中托管它来制作“桌面版”。

I'm a professional software developer, and while I write mainly enterprise web-based applications, I have played around with Visual Studio 2012 and Windows 8. Here's what I've discovered: 我是一名专业的软件开发人员,虽然我主要编写基于Web的企业应用程序,但我还是使用了Visual Studio 2012和Windows 8.以下是我发现的内容:

Since Metro is now a verboten term, I'll use the term "Tablet apps" to refer to full-screen apps and "Desktop apps" to refer to programs running on the Windows desktop. 由于Metro现在是一个禁止使用的术语,我将使用术语“平板电脑应用程序”来指代全屏应用程序,使用“桌面应用程序”来指代在Windows桌面上运行的程序。

I don't understand this picture well. 我不太了解这张照片。 In the Metro style Apps, what does C/C++ mean? 在Metro风格的应用程序中,C / C ++意味着什么? Native C/C++? 原生C / C ++? or is it managed C++? 或者它是托管C ++? They(Metro style apps) don't even have Win32 layer! 他们(Metro风格的应用程序)甚至没有Win32层!

All tablet apps use managed code. 所有平板电脑应用都使用托管代 This is because the WinRT operating system can't run x86 or AM64 instructions. 这是因为WinRT操作系统无法运行x86或AM64指令。 Both versions can run .Net code just fine, though. 不过,两个版本都可以运行.Net代码。 So all WinRT apps must use managed code, use a XAML UI, and they will only be distributed through the Windows Store. 因此,所有WinRT应用程序都必须使用托管代码,使用XAML UI,并且只能通过Windows应用商店分发。

To make an application which compatible with both Metro style and Desktop, should we only use .NET code? 要创建一个兼容Metro风格和桌面的应用程序,我们应该只使用.NET代码吗?

Yes. 是。 That's exactly right. 这是完全正确的。 You must use .Net code. 您必须使用.Net代码。 Old, native apps can NOT run on a Windows 8 tablet. 旧的本机应用程序无法在Windows 8平板电脑上运行。 If you're like most Windows devs who learned by doing, this is going to require an adjustment in how you write code. 如果您像大多数通过实践学习的Windows开发人员一样,则需要调整编写代码的方式。

Here's how I am approaching it: 这就是我接近它的方式:

A basic program that needs to operate on different form factors (tablet, desktop, phone) will have 3 classes. 需要在不同形状因素(平板电脑,台式机,手机)上运行的基本程序将有3个类。 The Model and the Controller classes will be implemented in a DLL, along with an Interface file that defines the GUI events and methods. Model和Controller类将在DLL中实现,以及定义GUI事件和方法的Interface文件。 The only thing that actually goes in to my .EXE files is the GUI. 实际进入我的.EXE文件的唯一事情就是GUI。 And the only logic in the GUI is basically to raise an event when the user performs actions on the form that require the program to do something. GUI中唯一的逻辑基本上是当用户在需要程序执行某些操作的表单上执行操作时引发事件。

For example, the user fills out his name on a text field, then clicks "Submit." 例如,用户在文本字段中填写他的名字,然后点击“提交”。 That would raise an Submitted event with the value from the Name box as a parameter. 这会引发一个Submitted事件,并将Name框中的值作为参数。 The controller can send feedback back to the form with a method, such as UpdateStatus() 控制器可以使用一种方法将反馈发送回表单,例如UpdateStatus()

It sounds complicated, and it takes more up-front design. 这听起来很复杂,需要更多的前期设计。 The beauty of this system is that once you implement the program for one form factor, all you have to do is modify your XAML for the other form factors. 这个系统的优点在于,一旦你为一个外形尺寸实现程序,你所要做的就是修改你的XAML以获得其他形状因子。 Your controller and your model don't change at all. 您的控制器和模型根本不会改变。 (I'm sure that someone will point out how to use XAML templates to do this, but I'm not there yet.) (我确信有人会指出如何使用XAML模板来做到这一点,但我还没有。)

As with Windows 7, 64 bit Windows doesn't support old 16 bit apps. 与Windows 7一样,64位Windows不支持旧的16位应用程序。 Other than that, yes, native apps are supported. 除此之外,是的,支持本机应用程序。

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

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