9 ms·
Calling Windows 10 APIs from a WinForms or WPF application
- diego_moita 10y agoSimilar tricks[0] can be used on Win32 applications. Although, I never got Intellisense working in VS if I declare #using <windows.winmd> 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-from-desktop-applications https://software.intel.com/en-us/articles/using-winrt-apis-f... [1] https://github.com/Microsoft/cppwinrt https://github.com/Microsoft/cppwinrt
- becarefulyo 10y agoThe article has Win32 examples too.
- Longhanks 10y agoUsing C++/CX (as seen by ref new). cppwinrt is ISO C++.
- pjmlp 10y agoC++/WinRT is still WIP. I wouldn't use it for production code until it reaches feature parity with C++/CX.
- becarefulyo 10y agoYou can use Windows Runtime Library (WRL) instead of C++/Cx. https://msdn.microsoft.com/en-us/library/hh438466.aspx https://msdn.microsoft.com/en-us/library/hh438466.aspx
- dorianm 10y agoSome Apple docs for comparison: https://developer.apple.com/library/content/samplecode/MetalGameOfLife/Introduction/Intro.html#//apple_ref/doc/uid/TP40017382-Intro-DontLinkElementID_2 https://developer.apple.com/library/content/samplecode/Metal...
- andrewpk 10y agoThat's just sample code. Actual docs look something like https://developer.apple.com/library/content/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Device/Device.html#//apple_ref/doc/uid/TP40014221-CH2-SW1 https://developer.apple.com/library/content/documentation/Mi...
- loarabia 10y agoWhat inference should I draw from the comparison to Apple docs? Also aren't you comparing a blog post to docs? (Apples and Oranges)
- tracker1 10y agoMy 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.
- dmitrygr 10y agoSee last few paragraphs.
- becarefulyo 10y agoThe 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/dynamically-detecting-features-with-api-contracts-10-by-10/ 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 }
- rymate1234 10y agoUnfortunately that's a Windows 10 API, meaning it isn't very useful for older versions of Windows!
- becarefulyo 10y agoIn that case, you put your Windows 10 stuff in a different .dll that doesn't get deployed on old versions of Windows. The article has an example.
- jmkni 10y agoI 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.
- pjmlp 10y agoI moved from Web back into Forms, WPF and Android. Couldn't be happier and dread of the next time I will have to switch customers, because of the high probability to return to web.
- miguelrochefort 10y agoWhy not port WPF to the web?
- pjmlp 10y agoI have a better idea, drop JavaScript from Web and leave it as pure HTML/CSS.
- digi_owl 10y agoAs a user i find going the other way more troubling. Say i want to use a UWP file manager on Windows 10. Out of the box the folders i can access are limited, and adding more require that i use the age old Win32 file picker window. Similarly both Google and Mozilla stopped developing a UWP native UI for their web browsers, as it would only be active if the browser was set as the default one. Something that is not always desirable. So from a user perspective, UWP feels bolted on rather than a integrated part.
- jug 10y agoI find UWP pretty terrible. :( It feels like developing for a weakest link (the traditional cross-platform problem) which is often Windows Phone or something. Which doesn't exist!! Windows Phone doesn't bloody exist! If MS had amazing mobile market penetration UWP would be amazing but what is this?! How is UWP exactly better than WPF for Windows desktop apps? It isn't. But it's where MS now wants you to be, because they have crazy deeams.
- mappu 10y ago>How is UWP exactly better than WPF for Windows desktop apps? CoreWindow lets you recolor the window decorations without having to owner-draw the entire thing. But that's all i've got.
- contextfree 10y agoWPF has a dependency on the CLR which made it a non-starter for the Windows and Office teams. That's the main reason WinRT/UWP XAML was developed in the first place; they wanted a developer platform they could use themselves, and those teams are unlikely to adopt C# anytime soon.
- pjmlp 10y agoActually WinRT/UWP are the Longhorn ideas, using the original design of .NET, originally known as COM+ Runtime. Also a reason why .NET is AOT compiled to native code on UWP.
- diimdeep 10y agoLook at this screenshot of context menus in Windows 10 https://pbs.twimg.com/media/C2Y6rwoXEAAaQll.jpg:large https://pbs.twimg.com/media/C2Y6rwoXEAAaQll.jpg:large win32, MFC, WinForms, WPF, Web.. Why don't stick to 1 framework and make it work good, deprecate rest, why have multiple buggy and ugly. If compare HTML/CSS and WPF improvement over last 15 years it is 10000 to 1. WPF could have been great 5 years ago, but I'm not sure it ever will be.
- ocdtrekkie 10y agoBecause Microsoft supports critical applications that businesses use for well over ten years in a lot of cases. Zero other operating systems have to provide the platform stability that Microsoft does. So, of course, if they have to focus on supporting only one, archaic platform, they never move forward or create anything new or improved. Which doesn't make sense. So you continue to create newer, better platforms, but continue to support the old ones for years to come. Eventually, older ones fall out of use and can eventually be retired.
- floopidydoopidy 10y agoThey only have to provide this because they lock down their products. They do it to themselves.
- ocdtrekkie 10y agoThis is only partially true. A large issue is that most of the software that runs on top of their products is also locked down. So when people have business critical software that's no longer supported by the original developer there's no way to fix it if the operating system gutted support for something they depend on.
- nikanj 10y agoTailor-made business-critical software is supported in a completely different way than your average shrink-wrap. "Sure we can update from Win32 to $modern. We estimate it to take between thirteen to seventeen man-months. You know the usual rate for a man-month, let us know when you want to start the project."
- frozenport 10y agoExcept the Native API and it's high performance timers!