How do I use Win32 structures from the Windows Runtime?

The Old New Thing (Raymond Chen) Tools

Summary

This article explains how to use Win32 structures in the Windows Runtime by declaring shadow structures with the same layout, including specific examples and alternatives for common structures.

<p>The Windows Runtime attempts to provide a language-independent interface for Windows APIs: The ABI is consistent across the Windows Runtime, and the APIs themselves are described via metadata, allowing each language to map the Windows Runtime concepts into concepts that are more natural for each target language. For example, the Windows Runtime <code>DateTime</code> maps to a corresponding date-time type for each target language, like <code>std::<wbr />chrono::<wbr />time_point</code> for C++ or <code>Date</code> for JavaScript. A cost of this goal is that the expressiveness of the Windows Runtime is constrained by the desire to make all the features available to all languages. For example, there are no raw pointers in the Windows Runtime.</p> <p>Win32 structures defined in classic C/C++ header files are not part of the Windows Runtime. So in a literal sense, you can&#8217;t use them from the Windows Runtime.</p> <p>But you can fake it.</p> <p>You can declare a shadow structure in the Windows Runtime that has the same layout as the classic Win32 structure you want to use. For example, you could declare your own Win32Point structure:</p> <pre>struct Win32Point { Int32 X; Int32 Y; }; </pre> <p>Note that the Windows Runtime has its own conventions for some things that in Win32 are represented by structures. For example, the <code>PROPERTYKEY</code> structure is represented conventionally in the Windows Runtime in its string form. You can use functions like <code>PSPropertyKeyFromString</code> and <code>PSStringFromPropertyKey</code> to convert between them.</p> <p>The post <a href="https://devblogs.microsoft.com/oldnewthing/20260521-00/?p=112345">How do I use Win32 structures from the Windows Runtime?</a> appeared first on <a href="https://devblogs.microsoft.com/oldnewthing">The Old New Thing</a>.</p>
Original Article
View Cached Full Text

Cached at: 05/22/26, 08:46 AM

# How do I use Win32 structures from the Windows Runtime? - The Old New Thing Source: [https://devblogs.microsoft.com/oldnewthing/20260521-00?p=112345](https://devblogs.microsoft.com/oldnewthing/20260521-00?p=112345) May 21st, 2026 0 reactions ![](https://devblogs.microsoft.com/oldnewthing/wp-content/uploads/sites/38/2019/02/RaymondChen_5in-150x150.jpg) The Windows Runtime attempts to provide a language\-independent interface for Windows APIs: The ABI is consistent across the Windows Runtime, and the APIs themselves are described via metadata, allowing each language to map the Windows Runtime concepts into concepts that are more natural for each target language\. For example, the Windows Runtime`DateTime`maps to a corresponding date\-time type for each target language, like`std::chrono::time\_point`for C\+\+ or`Date`for JavaScript\. A cost of this goal is that the expressiveness of the Windows Runtime is constrained by the desire to make all the features available to all languages\. For example, there are no raw pointers in the Windows Runtime\. Win32 structures defined in classic C/C\+\+ header files are not part of the Windows Runtime\. So in a literal sense, you can’t use them from the Windows Runtime\. But you can fake it\. You can declare a shadow structure in the Windows Runtime that has the same layout as the classic Win32 structure you want to use\. For example, you could declare your own Win32Point structure: ``` struct Win32Point { Int32 X; Int32 Y; }; ``` Note that the Windows Runtime has its own conventions for some things that in Win32 are represented by structures\. For example, the`PROPERTYKEY`structure is represented conventionally in the Windows Runtime in its string form\. You can use functions like`PSPropertyKeyFromString`and`PSStringFromPropertyKey`to convert between them\. ### Category ### Topics ## Author ![Raymond Chen](https://devblogs.microsoft.com/oldnewthing/wp-content/uploads/sites/38/2019/02/RaymondChen_5in-150x150.jpg) Raymond has been involved in the evolution of Windows for more than 30 years\. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie\-jeebies\. The Web site spawned a book, coincidentally also titled The Old New Thing \(Addison Wesley 2007\)\. He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information\. ## Read next ## Stay informed Get notified when new posts are published\. Follow this blog - [https://twitter.com/ChenCravat](https://twitter.com/ChenCravat) - [![youtube](https://devblogs.microsoft.com/oldnewthing/wp-content/themes/devblogs-evo/images/social-icons/youtube.svg)](https://www.youtube.com/playlist?list=PLlrxD0HtieHge3_8Dm48C0Ns61I6bHThc) - [https://github.com/oldnewthing](https://github.com/oldnewthing) - [https://devblogs.microsoft.com/oldnewthing/feed/](https://devblogs.microsoft.com/oldnewthing/feed/)

Similar Articles

How do I inform Windows that I’m writing a binary file?

The Old New Thing (Raymond Chen)

This article explains that Windows does not have a built-in concept of binary vs. text mode at the OS level; such distinctions are handled by runtime libraries like the C runtime. It clarifies that all files are treated as bytes by Windows and that content transformations must be done manually or via libraries.

Theseus: translating win32 to wasm

Lobsters Hottest

Translates Windows executables (win32/x86) to WebAssembly to run in the browser, discussing challenges like blocking vs async design.