您的位置:首页 > 其它

Windows Store 平台移植 —— (2) 了解开发环境

2013-11-19 12:04 399 查看

1、Windows Store 相关技术

随着 Win8 的发布,微软有给我们带来一系列的新概念,包括:

Windows Runtime
C++/CX
Windows Runtime C++ Template Library(WRL)

而一些原有的概念也与 Win 8 有关,比如:

COM
ATL
C++/CLI
.NET

2、C/C++移植相关技术

如果要将已有 C、C++ 程序移植到 Windows Store 环境,你应该了解的是:

Win32 API

Win32 API 不是什么新东西,之前在 windows 上做过开发的人都应该知道,比如 Sleep、CreateFile 等等。但是进入到 Windows Store 环境,这些 API 能用的大概就剩一半了。不管微软出于什么目的,删除了的这些 API,这是我们必须面对的问题。

MSDN 链接:

Win32
and COM APIs

Windows Runtime

Windows 8 增加了 Windows Runtime,Windows Runtime 是一种面向对象的跨语言的框架,Windows Runtime 组件能够被 C++、VB、C#、Javascript 调用。反过来,我们也可以将 C++ 实现的功能通过 Windows Runtime 提供给其他语言调用。

Windows Runtime API

随着 Windows Runtime 而来的是,一些提供系统基本功能的 Windows Runtime 组件,称为 Windows Runtime API。在 C++ 中可以使用这些组件功能。

MSDN 链接:
Windows
APIs: Windows Runtime

C++/CX

全新的C++/CX(组件扩展)语言是对 C++ 的扩展。C++/CX 支持 C++0x 标准,比如 auto 关键字、lamba 表达式和 右值引用(&&) 等等。C++/CX 的扩展功能能够与 Windows Runtime 组件交互,通过扩展的 ref 类(结构体)语法、value 类(结构体)语法实现。我们要调用 Windows Runtime 组件功能,以及将已有 C/C++ 库的功能提供给 UI 和 其他语言调用,都有通过 C++/CX 达成目的。

MSDN 链接:

Visual
C++ 语言参考 (C++/CX)

Creating
Windows Runtime Components in C++

3、移植的基本思路

基于对 Windows Store 的了解,我们做 C/C++ 移植主要的任务有:

Win32 API 补充

首先,我们需要通过 Windows Store 现有的 API 实现缺失的 Win32 API。实现的方式主要有下列几种:

通过 UNICODE 版本实现缺失的 ASCII 版本,比如 GetStringTypeExW -> GetStringTypeExA
通过提供相同功能的扩展版本 API 实现缺失的普通版本 API,比如 GetTickCount64 -> GetTickCount
通过 Windows Store 引入的替代功能 API 实现被替代的 API,比如 CreateFileMappingFromApp -> CreateFileMapping
通过 Windows Runtime API 实现一系列相关 API,比如 Windows::Socket 组件集 -> socket,WSASocket 系列 API
自行实现 Windows Store 没有的功能的 API,比如 GetEnvironmentVariable 环境变量功能

封装 Windows Runtime 组件

接着,需要将已有的 C/C++ 库封装为 Windows Runtime 组件,提供给其他代码调用。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐