How can I call an UWP API from a C++ desktop application - c++

I would like to access Bluetooth LE devices using the corresponding UWP APIs. However, my application is a "classic" C++ application (3D game) that can't run as a UWP app. Is there a way to do that? Accorind to enter link description here these APIs are published, but I don't know the steps to access them I have only found some posts for Windows 8/8.1 apps that include the Windows.winmd and Platform.winmd metadata files and set the /ZW compilation flag, but this doesn't seem to apply to Windows 10.

You should be able to do this, as the Bluetooth classes (e.g., BluetoothLEAdvertisement) are marked up with DualApiPartitionAttribute (callable from desktop and UWP apps).
Using one of the older Win8.1 desktop samples should give you a good starting point for calling the APIs without requiring /ZW or referencing the winmd files. A good example is the desktop toast API sample.
If you go that route, you can use classic COM to create the UWP/WinRT classes via WRL helpers.

You can use the web that you make a web server and the C++ application use the same server and if UWP send the info to server then it will send the info to C++ application.
To safe,the UWP can't use the desktop app.

Related

Windows Store App - remove fullTrustCapability

I'm developing a C++-Win32-app which should be deployed in the Microsoft Store. Unfortunately, since runFullTrustis added automatically as required capability, the program appears in Microsoft Store as follows: "This app can access all your files, peripheral devices, apps, programs and registry.", but I don't need all of those capabilities. Is there any possibility to get rid of the runFullTrust capability or to choose which capabilities are really needed?
If you want to publish the Win32 apps in Microsoft Store, and you must add restricted capability runFullTrust in the manifest.
Only UWP app can be published in the Microsoft Store,if you have an existing desktop application that was built using the .NET Framework (including WPF and Windows Forms) or C++ Win32 APIs, you can several options(Package your desktop application in an MSIX package, Use UWP APIs...) for moving to the UWP and Windows 10. The moved app called desktop bridge apps. You can see more details in document:
Move from a desktop application to UWP
The restricted capability runFullTrust is required for any desktop application that is delivered as an appx or msix package (as with the Desktop Bridge), and it will automatically appear in your manifest when packaging these apps using the Desktop App Converter (DAC) or Visual Studio. You can see this in document:
Restricted capabilities

Qt with webRTC how to implement

I need to transfer live desktop screen data(like remote desktop) to a client application a browser, and user can view remote desktop in browser, I am thinking of implementing it with webRTC and Qt. the webRTC data channel I can use to transfer the desktop data. Only problem is how to interface it with QT. When I look in internet I have few methods.
Implement with native c++ webRTC and communicate with the browser. I searched lot to get a working c++ webRTC application but couldn't successfully run.
Implement with Qt webengine and java script. I read documentation about Qt webkit bridge, I hope I can pass data between Qt C++ part and Javascript part without much delay.
And I am not sure is there any good method exist. Please suggest me the right method.

Two way communication between Chrome extention and win32 c++ application

I need advice about the best way to make an application (written in c++/mfc) communicate with an extension in chrome (I am also studying edge chromium)
As far as I understand, the native application that the extension can communicate with by using native host messaging is launched by chrome. As my win32 application is launched by the user and not by chrome, I need the native application to be a third component, launched by chrome.
What is the best way to let my win32 application communicate with my native app ? Making it a COM server is a good idea ?
I have searched on the other posts but they often talk about the native app talking to another app, not the other way.
Thank you

How to call UWP API from converted Win32 app. (Desktop App Converter)

I converted Win32 app (C++) to UWP one successfully.
But it can't work read/write file method, so I want to use UWP API from converted app.
Supported UWP APIs for converted desktop apps
I found this sentence "Most UWP APIs work well on converted desktop apps.".
But I can't find the way to call UWP API from converted Win32 app.
How to call UWP API from converted Win32 app ?
Thanks.
How to call UWP API from converted Win32 app ?
Actually, there are some samples in this offcial repository: DesktopBridgeToUWP-Samples
For example, the AppService Bridge Sample includes two projects: BackgroundProcess(Win32 Console application) and UWP(UWP app)
The BackgroundProcess project added reference to System.Runtime.WindowsRuntime and enable UWP AppService implementation, check ThreadProc function
The UWP project will use the new full trust capability to execute this Win32 application to consume the App service. See also Converted desktop app extensions
But it can't work read/write file method
In your scenario, you just need to complete UWP feature(StorageFile class) in the Win32 project and convert to the UWP app.
We have recently published a blog post about calling UWP APIs from Win32 processes. Those APIs generally can be called even without using the Desktop Bridge, but several are only applicable when using the UWP app model which the Desktop Bridge conversion provides:
https://blogs.windows.com/buildingapps/2017/01/25/calling-windows-10-apis-desktop-application
Thanks!

Host a c++ desktop application on a webpage

I am having a desktop application which having a UI interface made in Qt linked with a library which is doing all the calculation stuff. Values from UI is taken and pass to the API's in the DLL to get the output which is shown on Screen.
Now i want to do the same thing by transferring my application UI to a web page so that people can access the tool from anywhere without any installation process.
I want to retain my c++ DLL code so i don't have to do a lot of work. I am thinking of just converting this DLL to a C++ server by any communication Process(Sockets). I want to host this application on my company's website. (We have to make the website also so we are open to any set of tools).
I want to know what will be the best set of tools to do this stuff. Also there will be lot of data exchange between the webpage and server so the wholething should be optimized also. I goggled a bit and find stuff like silverlight and ASP.NET, But i am still not very clear which option will be more suitable.
I am a c++ programmer with no web application development experience. I am open to learn any new technology.
Thanks
Why not use Qt on the web directly? There are several projects like this one: http://qtwui.sourceforge.net/
There is a netscape plugin that will host a QT application and an ActiveX control wrapper on the QT website. You could use one of those to wrap your application. Note that this approach would require the user (or their administrator) to download and install the plugin.
An alternative approach might be to run your application through a remote desktop such as XVNC, NX or an RDP based layer. IIRC browser based remote desktop clients are available for most such protocols.
A few options:
pick a messaging/queue implementation (like http://www.zeromq.org/) and provide a service
implement a Windows Web Service if you want to be more enterprise friendly: http://msdn.microsoft.com/en-us/magazine/ee335693.aspx
I would not expose the implementation on the internet. Enough to have a simple buffer overflow and the machine can be taken over quickly. Adding a layer between the app and the web provides an easy way to validate input, access, stats ...
You should be able to use your DLL from an wt or cppcms application. Then you do not have to learn something new and can just use C++.
The way I'm currently doing this is with Boost.Python + django