<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Windows 8 Review &#187; dima</title>
	<atom:link href="http://win8review.com/author/dima/feed/" rel="self" type="application/rss+xml" />
	<link>http://win8review.com</link>
	<description>News about Windows 8 Tablets, Apps and all other things Win8</description>
	<lastBuildDate>Thu, 16 May 2013 15:41:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Good way of replacing Win32 File IO with WinRT functions</title>
		<link>http://win8review.com/2011/10/good-way-of-replacing-win32-file-io-with-winrt-functions/</link>
		<comments>http://win8review.com/2011/10/good-way-of-replacing-win32-file-io-with-winrt-functions/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 21:12:31 +0000</pubDate>
		<dc:creator>dima</dc:creator>
				<category><![CDATA[Windows 8 Apps]]></category>
		<category><![CDATA[Windows 8 Internals]]></category>
		<category><![CDATA[Windows 8 Software Development]]></category>
		<category><![CDATA[CreateFile]]></category>
		<category><![CDATA[CreateFile2]]></category>
		<category><![CDATA[IInputStream]]></category>
		<category><![CDATA[IRandomAccessStream]]></category>
		<category><![CDATA[IStream]]></category>
		<category><![CDATA[ReadFile]]></category>
		<category><![CDATA[Win32 IO and WinRT]]></category>
		<category><![CDATA[WinRT input output]]></category>
		<category><![CDATA[WriteFile]]></category>

		<guid isPermaLink="false">http://win8review.com/?p=129</guid>
		<description><![CDATA[I had a library which used Win32 functions to work with file system. It included CreateFile, CreateFile2, ReadFile, WriteFile. My goal was to quickly and effectively to replace it with WinRT functions and not to overwrite entire codebase. There are two options to work with this: auto pickOperation = openPicker-&#62;PickSingleFileAsync(); TextBlock^ result = Scenario1FileName; pickOperation-&#62;Completed [...]]]></description>
				<content:encoded><![CDATA[<p>I had a library which used Win32 functions to work with file system.</p>
<p>It included CreateFile, CreateFile2, ReadFile, WriteFile. My goal was to quickly and effectively to replace it with WinRT functions and not to overwrite entire codebase.</p>
<p>There are two options to work with this:</p>
<pre>    auto pickOperation = openPicker-&gt;PickSingleFileAsync(); 
    TextBlock^ result = Scenario1FileName; 
    pickOperation-&gt;Completed = ref new AsyncOperationCompletedHandler&lt;StorageFile^&gt;([&amp;wcstring,component,result](IAsyncOperation&lt;StorageFile^&gt; ^operation) 
    {</pre>
<pre>         IRandomAccessStream^ accessStream = operation-&gt;GetResults();</pre>
<pre>      // pass IRandomAccessStream to my library and use it for stream operations</pre>
<pre>         myFunction(accessStream);</pre>
<pre>    }</pre>
<pre></pre>
<p>Within the libary you could do following instead of ReadFile function</p>
<pre>IInputStream^ inputStream = accessStream-&gt;GetInputStreamAt(location);</pre>
<pre>DataReader^ dataReader  = ref new DataReader(inputStream);</pre>
<p>The disadvantage of this method is that DataReader doesn&#8217;t support Seek methods and you need to create IInputStream and DataReader objects for every read operation. This could cause memory and performance issues.<br />
Better alternative is following:</p>
<pre>    auto pickOperation = openPicker-&gt;PickSingleFileAsync(); 
    TextBlock^ result = Scenario1FileName; 
    pickOperation-&gt;Completed = ref new AsyncOperationCompletedHandler&lt;StorageFile^&gt;([&amp;wcstring,component,result](IAsyncOperation&lt;StorageFile^&gt; ^operation) 
    {</pre>
<pre>         IRandomAccessStream^ accessStream = operation-&gt;GetResults();</pre>
<pre>         ComPtr&lt;IStream&gt; sourceStream;
         HRESULT hr = CreateStreamOverRandomAccessStream(reinterpret_cast&lt;IUnknown*&gt;(accessStream), IID_PPV_ARGS(&amp;sourceStream));</pre>
<pre>         myFunction(sourceStream);</pre>
<pre>    }</pre>
<p>And for read operations you could do following:</p>
<pre>stream-&gt;Seek(largeIntLocation, origin, &amp;newLocation);</pre>
<pre>sourceStream-&gt;Read(data, readSize, &amp;returnSize);</pre>
<p>Which makes transition to WinRT much easier.<br />
Unfortunatelly there is no official documentatin for CreateStreamOverRandomAccessStream method and it is only available in WinRT samples. But I would guess if it is in samples it could be used by applications developers too.</p>
<pre><a href="http://code.msdn.microsoft.com/windowsapps/SaveAsImageFile-68073cb0/sourcecode?fileId=44807&amp;pathId=1697256490">http://code.msdn.microsoft.com/windowsapps/SaveAsImageFile-68073cb0/sourcecode?fileId=44807&amp;pathId=1697256490</a></pre>
]]></content:encoded>
			<wfw:commentRss>http://win8review.com/2011/10/good-way-of-replacing-win32-file-io-with-winrt-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WinRT and Simple String functions</title>
		<link>http://win8review.com/2011/10/winrt-and-simple-string-functions/</link>
		<comments>http://win8review.com/2011/10/winrt-and-simple-string-functions/#comments</comments>
		<pubDate>Tue, 25 Oct 2011 20:53:42 +0000</pubDate>
		<dc:creator>dima</dc:creator>
				<category><![CDATA[Porting C++ Code]]></category>
		<category><![CDATA[Windows 8 Apps]]></category>
		<category><![CDATA[Windows 8 Internals]]></category>
		<category><![CDATA[Windows 8 Software Development]]></category>
		<category><![CDATA[WinRT]]></category>
		<category><![CDATA[charlower]]></category>
		<category><![CDATA[chartupper]]></category>
		<category><![CDATA[platform string]]></category>
		<category><![CDATA[WINAPI_FAMILY_PARTITION]]></category>

		<guid isPermaLink="false">http://win8review.com/?p=127</guid>
		<description><![CDATA[I&#8217;ve been working on some existing code yesterday and bumped into a pretty ridiculous problem &#8211; how to convert WinRT Platform::String to lowercase or uppercase&#8230; In winuser.h following functions are marked as #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) CharUpperA CharUpperW CharLowerA CharLowerW and many more. It is fine with me &#8211; but what are replacements for them? In Platform::String I don&#8217;t see [...]]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been working on some existing code yesterday and bumped into a pretty ridiculous problem &#8211; how to convert WinRT Platform::String to lowercase or uppercase&#8230;</p>
<p>In winuser.h following functions are marked as #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)</p>
<p>CharUpperA</p>
<p>CharUpperW</p>
<p>CharLowerA</p>
<p>CharLowerW</p>
<p>and many more.</p>
<p>It is fine with me &#8211; but what are replacements for them? In Platform::String I don&#8217;t see anything that resembles ToLower or ToUpper&#8230;</p>
<p>I&#8217;ll keep investigating this and hopefully there is some simple method which I just overlooked.</p>
<p>There is a possible solution to use std tolower and toupper function but it seems like a bit an overkill for such a simple operation and wchar_t string&#8230;</p>
<pre><code>std::transform(a.begin(), a.end(), a.begin(), 
    std::bind2nd(std::ptr_fun(&amp;std::tolower&lt;char&gt;), std::locale("")));</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://win8review.com/2011/10/winrt-and-simple-string-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
