operation->GetResults() get null pointer!!
-
Donnerstag, 12. April 2012 13:26
Hi all:
I use WRL method for file access.
However, now I usually OpenAsync() failed.
Because [operation->GetResults(&PanoramaFile)] usually get null pointer. (Sometimes it's ok!)
The code is as below.
(The full code http://social.msdn.microsoft.com/Forums/en-US/winappswithnativecode/thread/f79d829f-8445-454a-b8d6-83cc3bc6b615)
===========================================================================================
HString hstrFileName;
hstrFileName.Set(L"sample.txt");// Call CreteFileAsync
__FIAsyncOperation_1_Windows__CStorage__CStorageFile_t * operation;hr = pStorageFolder->CreateFileAsync(hstrFileName.Get(),
CreationCollisionOption::CreationCollisionOption_ReplaceExisting,
&operation);
if (FAILED(hr))
{
::Microsoft::WRL::Details::RaiseException(hr);
}
operation->GetResults(&PanoramaFile);__RPC__deref_out_opt __FIAsyncOperation_1_Windows__CStorage__CStreams__CIRandomAccessStream *RandomStream;
PanoramaFile->OpenAsync(FileAccessMode_ReadWrite, &RandomStream);
===========================================================================================
Alle Antworten
-
Donnerstag, 12. April 2012 22:27Moderator
The problem is that the results aren't ready. CreateFileAsync is an asynchronous function and will take some time to complete. You cannot get the results until it has completed.
See Asynchronous programming in C++ for more information on how to handle asynchronous calls.
--Rob
- Als Antwort vorgeschlagen Jesse JiangMicrosoft Contingent Staff, Moderator Freitag, 13. April 2012 02:50
- Als Antwort markiert Steve HorneMicrosoft Employee, Moderator Dienstag, 24. April 2012 23:53

