https://visualstudiomagazine.com/articles/2021/01/21/win32-apis.aspx [eof] [ ] [Search] [eof] Visual Studio Magazine - Expert Solutions for .NET Development Open Menu Open Menu * Home * News * Tips & How-To * Newsletters * White Papers * Webcasts * Advertise * About Us * Events * More + .NET Tips and Tricks + The Data Science Lab + Practical .NET + The Practical Client + Data Driver + C# Corner + In-Depth + PDF Back Issues + HTML Issue Archive + Archive + Code Samples + .NET + Agile/Scrum + ALM + Open Source + SharePoint + Cross-Platform C# + Mobile Corner + Live! Video * [twitter] * [facebook] * [linkedin] * [rss] * [search] * [searchclos] * Visual Studio * Visual Studio Code * C#/VB * .NET * Xamarin/Mobile * TypeScript/Blazor/ASP.NET * AI/Machine Learning * Azure [eof] [eof] News Microsoft Opens Up Old Win32 APIs to C# and Rust, More Languages to Come * By David Ramel * 01/21/2021 [041613Move] Microsoft is opening up old Win32 APIs long used for 32-bit Windows programming, letting coders use languages of their choice instead of the default C/C++ option or individual workarounds. As its name bespeaks, Win32 is the 32-bit API for versions of Windows from 95 and later. Although Win32 APIs could previously be used in other languages besides C/C++, that required workarounds -- wrappers or bindings -- such as the familiar P/Invoke scheme for C#. However, using P/Invoke and its Rust counterpart, winapi-rs, is cumbersome because the individual offerings must be manually maintained, making it hard to keep up sustained coverage. What's more, such a scheme doesn't translate to other languages. To simplify and automate the process, Microsoft today (Jan. 21) introduced its win32metadata project, along with a couple of initial Win32 language projections. A programming language projection is a subsystem -- variously described as a set of wrappers or an adapter -- that fosters development using the APIs of a platform (Win32 in this case) in a natural and familiar way for the target language. The metadata project eases the creation of language projections by providing a complete description of the Win32 API surface so it can be automatically projected to any language, which Microsoft said improves correctness and minimizes maintenance. Thus these metadata descriptions aren't meant to be consumed directly by developers, who instead will use the language projections that in turn consume the metadata and project the APIs into the natural patterns of specific languages. Calling CreateFile via PInvoke Static Class with C#/Win32 in Animated Action [Click on image for larger, animated GIF view.] Calling CreateFile via PInvoke Static Class with C#/Win32 in Animated Action (source: Microsoft). [eof] "Win32 APIs have existed for a long time, so accurately describing all of them will take some iteration," Microsoft said in a blog post. "We will be developing this tooling in the open and welcome community contributions to ensure an accurate representation of the Win32 API surface that will benefit all languages." In the meantime, Microsoft introduced two initial language projections in preview: * C#/Win32: "Built in partnership with Andrew Arnott, the owner of the PInvoke project for .NET, C#/Win32 parses the metadata and generates the P/Invoke wrappers required to call the APIs you care about." * Rust: "The Rust language projection follows in the tradition established by C++/WinRT of building language projections for Windows using standard languages and compilers, providing a natural and idiomatic way for Rust developers to call Windows APIs. The windows crate lets you call any Windows API using code generated on the fly directly from the metadata, enabling you to call the APIs as if they were just another Rust module." Going forward, Microsoft said it's already working on a Modern C++ projection. The company said, "True, the Windows SDK already releases headers that can be consumed from C++, but those headers have some severe historical and compatibility constraints that hamper C++ developers that wish to enjoy modern language features." In creating more language projections, the company said it will follow these principles: * Language projections should provide maximum API coverage * Language projections should provide friendly adaptations of APIs and types where appropriate * Language projections should provide IntelliSense sourced from official documentation * Language projections should support filtering available APIs based on the SDK version that a project targets * Language projections should enable developers to target a specific set of APIs and link or include only the artifacts necessary to provide support for those APIs In addition to providing C#, C++ and Rust projections in preview, the project's roadmap indicates that Win32 metadata package will be published to NuGet.org in preview for the most recent Windows SDK version during Microsoft's //BUILD 2021 developer conference set for mid May. About the Author David Ramel is an editor and writer for Converge360. Printable Format Please enable JavaScript to view the comments powered by Disqus. comments powered by Disqus Featured * [Debug] Python in VS Code Adds Data Viewer for Debugging The January 2021 update to the Python Extension for Visual Studio Code is out with a short list of new features headed by a data viewer used while debugging. * [eof] * [OctocatLea] GitHub Ships Enterprise Server 3.0 Release Candidate It's described as "the biggest ever change to Enterprise Server," with improvements to Actions, Packages, mobile, security and more. * [0913vsm_mi] Attacks on .NET Apps Grow in Number, Severity, Says Security Firm .NET apps were found to have more serious vulnerabilities and suffer more attacks last year, according to data gathered by Contrast Labs. * [041613Move] Microsoft Opens Up Old Win32 APIs to C# and Rust, More Languages to Come Microsoft is opening up old Win32 APIs long used for 32-bit Windows programming, letting coders use languages of their choice instead of the default C/C++ option. Most Popular * Most Popular Articles * Most Emailed Articles Microsoft Opens Up Old Win32 APIs to C# and Rust, More Languages to Come Radzen Open Sources 60+ Blazor Components Project Oqtane Provides Blazor-Based Modern App Framework GitHub Ships Enterprise Server 3.0 Release Candidate Python in VS Code Adds Data Viewer for Debugging [eof] .NET Insight Sign up for our newsletter. Email Address*[ ]Country* [ ] I agree to this site's Privacy Policy [Captcha] Please type the letters/numbers you see above. [ ] [Submit] [eof] * Most Popular Articles * Most Emailed Articles Microsoft Opens Up Old Win32 APIs to C# and Rust, More Languages to Come Radzen Open Sources 60+ Blazor Components Project Oqtane Provides Blazor-Based Modern App Framework GitHub Ships Enterprise Server 3.0 Release Candidate Python in VS Code Adds Data Viewer for Debugging [eof] [eof] Free Webcasts * What's Ahead for .NET Development in 2021: Half-Day Virtual Summit * The MSIX Journey: What have we learned? * Hottest Third Party .NET Tools * How Blazor Changes Web Development > More Webcasts [eof] Upcoming Events * Visual Studio Live! Virtual Training March 23-24, 2021 * Visual Studio Live! Virtual Training April 13-14, 2021 * Visual Studio Live! Virtual Training May 4-5, 2021 * Visual Studio Live! Virtual Training June 22-23, 2021 * Visual Studio Live! Microsoft HQ August 9-13 2021 Redmond, WA * Visual Studio Live! San Diego September 12-16, 2021 San Diego, CA * Live! 360 Orlando November 14-19, 2021 Orlando, FL [eof] [eof] [eof] * Contact Us * Advertise * Events * Print Issues Online * Free Newsletters * Site Map * Reprints * List Rental [eof] [eof] [converge36] [1105compan] * Application Development Trends * AWSInsider.net * Enterprise Systems * FutureTech360 * Live! 360 * MCPmag.com * Prophyts * Pure AI * Redmond * Redmond Channel Partner * TechMentor Events * Virtualization & Cloud Review * Visual Studio Magazine * Visual Studio Live! © 1105 Media Inc. See our Privacy Policy, Cookie Policy and Terms of Use. CA: Do Not Sell My Personal Info Problems? Questions? Feedback? E-mail us. [eof]