2017-06-16 29 views
-1

我有一個Windows通用C++應用程序和一個WebView,它調用一個返回字符串的Javascript函數。現在我想一個Windows::Foundation::IAsyncOperation<String^>^轉換爲std::string將Windows :: Foundation :: IAsyncOperation <String^> ^轉換爲std :: string

這裏是調用JavaScript函數

Windows::Foundation::IAsyncOperation<String^>^ result = this->webView1->InvokeScriptAsync("JSfunction", arguments); 
代碼

我想有resultstd::string

回答

1

resultString^型的不,它是IAsyncOperation<String^>,異步操作返回一個String ^給它的調用者。

要獲得類型String^的結果,請在IAsyncOperation上調用GetResults方法。

String^ result = this->webView1->InvokeScriptAsync("JSfunction", arguments)->GetResults(); 

然後,您可以將字符串^轉換爲符合Q: C++/CLI Converting from System::String^ to std::string的std :: string。