-1

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.

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51
fireflower
  • 21
  • 2
  • What have you already tried? If anything, please edit your question to include your code, which can often help the SO community to provide a better answer. – Sebastian Lenartowicz Aug 25 '16 at 02:44
  • 3
    *"it can't work read/write file method"* - [File access](https://msdn.microsoft.com/en-us/windows/uwp/files/file-access-permissions) is restricted in a UWP application. You cannot work around the restrictions by using a different API. – IInspectable Aug 25 '16 at 07:57
  • I had a misunderstanding. Thank you for replying, guys. – fireflower Aug 25 '16 at 08:56

2 Answers2

1

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.

Franklin Chen - MSFT
  • 4,845
  • 2
  • 17
  • 28
  • The reason for the failure was i thought converted win32 app can write to installed directory. [link](https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-root). I noticed my misunderstanding when i saw this sentence "Your app writes to the install directory for your app." in this site. Changing folder makes me successeed writing. But I think it would be better to use winRT API. So I will replace old api to winRT's one. Thanks for replying. – fireflower Sep 01 '16 at 13:00
1

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!

Stefan Wick MSFT
  • 13,600
  • 1
  • 32
  • 51