2

背景:スマートカードリーダープラグイン(カード挿入)イベント

私は、スマートカードからのいくつかのデータを読み込むのWindows 10ユニバーサルアプリケーションを作成しています(スマートカードリーダーに挿入された)、それが正常に動作していますすべての場合において、ユーザはカードからデータを読み取るためにプロセスを起動する必要があります。

質問:私はUWPで「カード挿入イベント」を扱うことができ、それが挿入された後、私はカードからデータを毎回読むことができますどのように

答えて

1

私はUWPに慣れていませんが、私はこれを見つけましたexample

これは、スマートカードリーダーのインスタンスを作成:

private SmartCardReader reader = provisioning.SmartCard.Reader; 

とそれにCardAddedハンドラを追加する:

reader.CardAdded += HandleCardAdded; 

このようHandlerCardAddedに見える:

void HandleCardAdded(SmartCardReader sender, CardAddedEventArgs args) 
{ 
    // This event handler will not be invoked on the UI thread. Hence, 
    // to perform UI operations we need to post a lambda to be executed 
    // back on the UI thread; otherwise we may access objects which 
    // are not marshalled for the current thread, which will result in an 
    // exception due to RPC_E_WRONG_THREAD. 
    uiContext.Post((object ignore) => 
    { 
     rootPage.NotifyUser("Card added to reader " + reader.Name + ".", NotifyType.StatusMessage); 
    }, null); 
} 

はこれがあなたのお役に立てば幸いです少し。

関連する問題