Live data from Hacker News

Calling Windows 10 APIs from a WinForms or WPF application

blogs.windows.com

1–10 of 71 posts

Re: Calling Windows 10 APIs from a WinForms or WPF application

#2
Similar tricks[0] can be used on Win32 applications.

Although, I never got Intellisense working in VS if I declare #using in C++/Win32 projects.

A simpler and a lot more interesting alternative (for Win32) is the excellent cppwinrt library[1]

[0] https://software.intel.com/en-us/articles/using-winrt-apis-f...

[1] https://github.com/Microsoft/cppwinrt

Re: Calling Windows 10 APIs from a WinForms or WPF application

#4
My only concern would be supporting older versions of windows while utilizing features where available. Would have been cool to see an example of doing this in the article.

Just the same, it's cool that it can be added without having to completely migrate/rework an application.

Re: Calling Windows 10 APIs from a WinForms or WPF application

#6
post #4

My only concern would be supporting older versions of windows while utilizing features where available. Would have been cool to see an example of doing this in the article. Just the same, it's cool that it can be added without having to completely migrate/rework an application.

See last few paragraphs.

Re: Calling Windows 10 APIs from a WinForms or WPF application

#7

Similar tricks[0] can be used on Win32 applications. Although, I never got Intellisense working in VS if I declare #using in C++/Win32 projects. A simpler and a lot more interesting alternative (for Win32) is the excellent cppwinrt library[1] [0] https://software.intel.com/en-us/articles/using-winrt-apis-f... [1] https://github.com/Microsoft/cppwinrt

The article has Win32 examples too.

Re: Calling Windows 10 APIs from a WinForms or WPF application

#8
post #4

My only concern would be supporting older versions of windows while utilizing features where available. Would have been cool to see an example of doing this in the article. Just the same, it's cool that it can be added without having to completely migrate/rework an application.

The Windows 10 API provides API availability checks. So you target the latest version but then add checks to see what API's are available.

This is nice because it encapsulates both OS version API differences and device capabilities.

https://blogs.windows.com/buildingapps/2015/09/15/dynamicall...

    using Windows.Foundation.Metadata;
     
    if(ApiInformation.IsTypePresent("Windows.Media.Playlists.Playlist"))
    {
        await myAwesomePlaylist.SaveAsAsync( ... );
    }

    if(ApiInformation.IsApiContractPresent("Windows.Media.Playlists.PlaylistsContract"), 1, 0)
    {
       // Now I can use all PlayList APIs
    }

Re: Calling Windows 10 APIs from a WinForms or WPF application

#9
I absolutely love WPF development.

I'm all web now, and I love it too, but sometimes I just wish I could go back to the good old WPF days!

The extensive tooling involved with frontend web development and the constant religious wars between frameworks can get exhausting.

Re: Calling Windows 10 APIs from a WinForms or WPF application

#10
post #4

My only concern would be supporting older versions of windows while utilizing features where available. Would have been cool to see an example of doing this in the article. Just the same, it's cool that it can be added without having to completely migrate/rework an application.

The Windows 10 API provides API availability checks. So you target the latest version but then add checks to see what API's are available. This is nice because it encapsulates both OS version API differences and device capabilities. https://blogs.windows.com/buildingapps/2015/09/15/dynamicall... using Windows.Foundation.Metadata; if(ApiInformation.IsTypePresent("Windows.Media.Playlists.Playlist")) { await myAwesomePl…

Unfortunately that's a Windows 10 API, meaning it isn't very useful for older versions of Windows!
Post reply on HN