introducing windows runtime
Post on 02-Jan-2016
74 Views
Preview:
DESCRIPTION
TRANSCRIPT
Introducing Windows RuntimeHokuriku.NET vol.152014/8/30 Sat
遥佐保(はるか・さお)
はじめに
@hr_saoRoom metro Osaka
C++ テンプレート読書会
Microsoft MVP for Client App Dev[Jan,2010-Dec,2013]Microsoft MVP for Client Development [Jan,2014-Jun,2014]
Microsoft MVP for Windows Platform Development [Jul,2014-Dec,2014]
Windows Runtime のファンを増やす!
もっと一緒に勉強してくれる人が増えたらいいな…
本日の目的
1. Windows Runtime architecture
2. Process
3. Features
4. Visual Studio Template
5. Universal windows apps
6. Windows store
7. Add deployment
Topics
1. Windows Runtime architecture
Windows Runtime Technology Stacks
Windows SDKs
WinRT (native)
XAML-Windows8.1
DirectX / XAML-DirectX11.2
C/C++-C++11
CRT
HTML / CSS-Trident
C# / VB FCL JavaScript-Chakra
WinJS
描画
言語
VM CLR(native) Internet Explorer-WWAHost.exe
Win32 / COM
• Core• Controls• Data and content• Devices• Files and Folders
• Globalization• Graphics• Helpers• Media• Networking• Printing
• Presentation• Remote Desktop• Security• Social• UI Automation• User interaction
API
( 公開されている機
能 )
DesktopWindows Store
Apps
Windows Store Apps から Win32/COM へは、原則呼び出し禁止
Windows Store Apps から呼び出しを許可されている COM はある http://msdn.microsoft.com/en-us/library/br205753
Win32 and COM for Windows Store apps
Windows SDKs
Windows Runtime Win32 / COM
Desktop AppsWindows Store Apps
Windows SDKs
Windows Runtime
Use Language
Windows Store Apps
C/C++-C++11
C# / VB JavaScript-Chakra
全ての言語から利用できるための API とは?WinMD ファイル – metadata (ECMA-335)
• C:\Windows\System32\WinMetadata にある• .winmd 拡張子• 型やメンバが
記述されている
Windows MetaData
メタデータを記載しているWindows Runtime の実体は EXE や DLLHKLM\Software\Microsoft\WindowsRuntime\ActivatableClassId
WinMD <-> DLL
Windows SDKs
Windows Runtime
Application Binary Interface
Windows Store Apps
C/C++ C# / VB JavaScript
Application Binary Interface
Windows Runtime は全て、 ABI を通じて API 提供を行う
Windows SDKs
Windows Runtime
WinRT API projection - C#/VB
Windows Store Apps
Windows Runtime
WinMD
1. コンパイル時にWinMD を解析
C# / VB
2. 実行時、 CLR が WinMD を利用して WinRT API を呼び出す
1
2
CLR
Windows SDKs
Windows Runtime
WinRT API projection - C++/CX
Windows Store Apps
C/C++
Windows Runtime
WinMD
1. コンパイル時に WinMD を解析2. 実行時 C++(native) から WinRT API を直接呼び
出す
1
2
Windows SDKs
Windows Runtime
WinRT API projection - JavaScript
Windows Store Apps
Windows Runtime
WinMD
実行時、 IE(WWAHost.exe) が WinMD を解析しJavaScript から WinRT API を呼び出す
JavaScript
Internet Explorer-WWAHost.exe
Windows SDKs
Windows Runtime
Windows Store Apps
C/C++ C# / VB JavaScript
Application Binary Interface
Windows Runtime と ABI のおかげで、各言語の相互利用が可能
2. Process
プロセスが Active 化するのは 2 パターン• メインビューのアクティブ化
Activation (1)
Activation (2)• ホステッドビューのアクティブ化
例えば「共有」で出てくるやつ
アクティブ化の方法は 2 つあるWindows ストアアプリのインスタンスは 1 つ - App オブジェクトはシングルトン
Initialization
Process life time
アプリに終了の概念はなし待機時、バックグラウンドタスクを実行できる
Background task
3. Features
• パッケージデータ• ストレージ• ストリーム• ネットワーク• 通知• バックグラウンドタスク
Windows Runtime Features• 共有• 広告• アプリ内課金
Package Data
Windows::Storage::ApplicationData::Current
いわゆるセーブ領域• テンポラリ保存• ローカル保存• ローミングC:\Users\[ ユーザ名 ]\AppData\Local\Packages \[ パッケージファミリ名 ]\LocalState\_sessionState.dat
ApplicationData
Package.appxmanifest
Notification
?
Push Notification
Windows Push Notification Services
(1) ストアアプリの初回起動で PushNotificationChannelManager .CreatePushNotificationCahnellForApplicationAsync() を実行
(1) (2)
(2) Web サービスにチャネル URI (さっき (1) で取得したもの)を 送信する ※ 30 日で期限は切れる URI (例) https://xxx.notify.windows.com/?token=xxx
Push Notification
Windows Push Notification Services
(3) 取得した URI(2) に、通知したいメッセージを付けて WNS に送信する ※アプリ開発者だけが知っているクライアントシークレットを 付けて OAuth トークンを発行してもらう
(1)
(3)
(4) タイルの更新やトースト通知が実施される
(2)(4)
Sharing data between apps
クリップボードはシステムで 1 つだけstatic 実装されているWindows.ApplicationModel.DataTransfer.Clipboard
Sharing data - Clipboard
例
←
←IE のリンクを受け取る FB アプリ
Shareing
共有ソースアプリ(共有するデータを持っている)
ターゲットアプリ(共有されたデータを受け取る)
ソースアプリ( IE )で共有したいものをDataPackage に入れておく ※ターゲットアプリ( FB )と共有できるWindows.ApplicationModel.DataTransfer.DataPackage
Sharing data - DataPackage
共有チャームで共有
Advertisement
* Windows ストア アプリで収益を上げるには - http://www.microsoftvirtualacademy.com/training-courses/decode-track1
Microsoft Advertising SDK のインストール - http://adsinapps.microsoft.com/ja-jp/sdk
Microsoft pubCenter に登録 - https://pubcenter.microsoft.com
Ad Control の貼り付け
Advertisement
テスト用のコードが簡単に利用できる<UI:AdControl ApplicationId="d25517cb-12d4-4699-8bdc-52040c712cab“ AdUnitId="10043104" />
自分のやつはpubCenter で Get!
Ad control
アプリ内課金Windows.ApplicationModel.Store
• アプリケーションのライセンスの状態を確認(評価版またはアクティブなライセンスなど)
• アプリ内機能の確認• アプリ内購入
4. Visual Studio Template
IPropertySet^ vals = ApplicationData::Current->LocalSettings->Values;if( vals->HasKey( "my_data” )){ vals->Remove( “my_data");}vals->Insert( "my_data", “Hokuriku" );
if( pageState->HasKey( "my_data” )){ pageState->Remove( “my_data" );}pageState->Insert( "my_data", “Hokuriku" );
Ex) ApplicationDataApplicationData を直接使う
VS テンプレートの NavigationHelper クラスの pageState を使う
VS 付随のプロジェクトテンプレートがあるテンプレート固有話なのか? WinRT の話なのか?
Visual studio Template
5. Universal windows apps
• 1 つのソースで Windows ストアアプリとWindows Phone アプリの開発が出来る - ただし、 XAML は別
• どちらかのストアで購入すると、もう片方でも購入済みになる
• データが同期される* めとべや東京 #4 の資料公開。「ユニバーサル Windows アプリ入門」 # めとべや東京 - http://okazuki.hatenablog.com/entry/2014/05/31/153328
これからプロジェクトを作るなら、ユニバーサルがおススメ
Windows Phone → Universal apps いばらの道
Windows store apps → Universal apps まぁ出来る
Universal apps → Windows store apps
WP 版を使わなければよい
Universal apps → Windows Phone ストア版を使わ
なければよい
6. Windows store
https://msdn.microsoft.com/ja-jp/windows/apps
Windows Developer Center
ストアへのお布施(年単位)
とにかく名前を登録する
プッシュ通知などに必要な情報はここでしか得られない(※企業用は別)
app for certification
Live Services sitehttp://msdn.microsoft.com/ja-jp/library/windows/apps/xaml/hh868206.aspx
単なる Azureの宣伝なので
無視
大事なのはここ!Live サービスサイ
ト
アプリ内課金
7. App deployment
「アプリをデプロイする」「配布する」とは?
→開発者が Windows ストアに 自分のアプリを登録すること
※その後、ユーザはアプリをクライアント PC に インストールする
Deployment …?
(1) Visual Studio で開発し Visual Studio から実行• 開発者ライセンスを使って実行
- 無料ライセンス( 30~ 90 日程度で更新かな ? )
• もちろん VS 持ってないとダメ
How to Install (1/4)
(2) Add-AppxPackage PowerShell コマンドを用いてインストールする• 開発者ライセンスを使って実行• パッケージの証明書入れる必要あり
( CertUtil.exe )• Add-AppxPackage でインストール* # めとべや 東京 2 で Sideloading Windows Store apps with PowerShell について発表してきました 資料公開http://tech.guitarrapc.com/entry/2013/10/15/073820
How to Install (2/4)
(3) 企業内でサイドローディングして配布する• ActiveDirectory参加必須
- なので無印WindowsRT はだめ(企業向け)• エンタープライズサイドローディングキーを別途
購入する必要がある* WINDOWS ストア アプリのサイドローディングについてhttp://blogs.msdn.com/b/japan_platform_sdkwindows_sdk_support_team_blog/archive/2014/03/12/2014-03-12-windows.aspx
How to Install (3/4)
Open License, Select Plus で購入可能Windows 8.1 Enterprise Sideloading (10 Pack) と Windows 8.1 Enterprise Sideloading (100 Pack) があ
る
(4) Windows ストアに出す!• マイクロソフトがアプリを事前にチェック• 合格したものだけをストアに出展• ストアに出すためにアプリ開発契約者(有料)に
なる必要がある• Windows ストアから Download & Instatll
How to Install (4/4)
Fun…
• クライアントで動作する Windows Runtimeの仕組みを知る
• Windows Runtime の固有機能を知る• その次に Visual Studio Template/Universal
windows apps
• Windows ストアの登録、配布、インストールも忘れずに
Let’s Windows Runtime
プログラミングWindowsRuntime
参考
top related