none
[UWP][C++][Desktop Bridge]How to get filesystem full access permission? RRS feed

  • 问题

  • My app need scan files in other place, I tried to use FolderPicker to get the user selected folder,  and add this folder to StorageApplicationPermissions.FutureAccessList, This method allows my app to access files in this folder, but only allow the use of UWP Async C++ API to get files, access file information, and read file content, for example:

    folder->GetFilesAsync();
    storageFile.getBasicPropertiesAsync();
    Windows::Storage::FileIO::ReadTextAsync(sampleFile);

    My app dependent library used C standard library operating interface, like fopen(), fread(), fclose(), however, these functions operate on files in other locations will return an error, the error message is "Access Denied".

    I know that if the existing file operation code conversion to asynchronous implementation, and package file stream operation interface to the dependent library to call, these workload is relatively large.

    This article said that the program can be converted to UWP win32 application and the converted applications have filesystem full access permission, which is exactly what I need, so what can I do to make my application retain the existing UWP C++ Interface call code, but also have filesystem full access permission?

    I have tried to convert win32 application into UWP application some time ago, but when running it will display two windows, one is the window to splash screen, one is to apply their own main window. how to solve this problem? How to close the splash screen window, or how directly to the application window splash screen as the main window?





    2016年12月7日 10:04

答案

  • Hello lc-soft,

    The article  you showed actually doing the following process for us. When we have a classic desktop application and we want to convert it to a UWP app to take benefit from some features, we will convert our installer use desktop bridge and then we will get an appx. See here  to understand the process, if we manually do this you will find all you need is to create a manifest and add something such as your exe location and the resource file you need. 

    So for your question:

    >>so what can I do to make my application retain the existing UWP C++ Interface call code, but also have filesystem full access permission?

    Actually I think you may need to re-construct your app. Please see the official sample from here. Where I recommend you check "AppService Bridge Sample" as a start. You will find that there is a UWP app and a classic desktop app. You can use your "My app dependent library used C standard library operating interface" in your classic desktop app and in UWP use something like the following to call it:

    // Make sure the BackgroundProcess is in your AppX folder, if not rebuild the solution
                    await Windows.ApplicationModel.FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
     

    In this way you can do anything you want in your win32 service app and then in UWP you just need to communicate to this win32 app.  See more details from NorthwindSample

    >>how to solve this problem? How to close the splash screen window, or how directly to the application window splash screen as the main window?

    Actually I didn't meet this kind of problem before. Can you show me a screenshot? I suspect this is a problem with your original desktop application. When I convert my simple desktop app it shows quickly without any splash screen.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 lc-soft 2016年12月8日 15:17
    2016年12月8日 8:51
    版主

全部回复

  • Hello lc-soft,

    The article  you showed actually doing the following process for us. When we have a classic desktop application and we want to convert it to a UWP app to take benefit from some features, we will convert our installer use desktop bridge and then we will get an appx. See here  to understand the process, if we manually do this you will find all you need is to create a manifest and add something such as your exe location and the resource file you need. 

    So for your question:

    >>so what can I do to make my application retain the existing UWP C++ Interface call code, but also have filesystem full access permission?

    Actually I think you may need to re-construct your app. Please see the official sample from here. Where I recommend you check "AppService Bridge Sample" as a start. You will find that there is a UWP app and a classic desktop app. You can use your "My app dependent library used C standard library operating interface" in your classic desktop app and in UWP use something like the following to call it:

    // Make sure the BackgroundProcess is in your AppX folder, if not rebuild the solution
                    await Windows.ApplicationModel.FullTrustProcessLauncher.LaunchFullTrustProcessForCurrentAppAsync();
     

    In this way you can do anything you want in your win32 service app and then in UWP you just need to communicate to this win32 app.  See more details from NorthwindSample

    >>how to solve this problem? How to close the splash screen window, or how directly to the application window splash screen as the main window?

    Actually I didn't meet this kind of problem before. Can you show me a screenshot? I suspect this is a problem with your original desktop application. When I convert my simple desktop app it shows quickly without any splash screen.

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • 已标记为答案 lc-soft 2016年12月8日 15:17
    2016年12月8日 8:51
    版主
  • >> Actually I think you may need to re-construct your app. Please see the official sample from here. Where I recommend you check "AppService Bridge Sample" as a start. You will find that there is a UWP app and a classic desktop app.

    You give the method seems feasible, I can move the file operation code to the win32 service app, so the main app only need to send the file operation command to the win32 service app, and then handle it return results.

    >> Actually I didn't meet this kind of problem before. Can you show me a screenshot? I suspect this is a problem with your original desktop application. When I convert my simple desktop app it shows quickly without any splash screen.

    The following is my app screenshot, The white background window on the bottom is the splash screen, The window on the top is the main window of my app. 

    After I discovered the problem, I started writing UWP-compliant code for my application, and now I've completed some of the compatible code, but I found that there are restrictions on file operations. So I submitted this question.


    • 已编辑 lc-soft 2016年12月8日 10:46 update content
    2016年12月8日 10:31
  • @lc-soft,

    For the second problem, I'm thinking about how we can solve this. Could you please check your converted app folder. Then navigate to your PackageFiles? You will be able to find a AppxManifest.xml file. Please check whether you can find the following:

    <uap:VisualElements DisplayName="MyTestApp1" Description="MyTestApp1" BackgroundColor="#777777" Square150x150Logo="Assets\SampleAppx.150x150.png" Square44x44Logo="Assets\SampleAppx.44x44.png" />

    I want you to check whether you can find the splashscreen from the above line. If you can find it, try backup your AppxManifest.xml file and then modify to delete the splashscreenimage from here. Also you can remove the splashscreen from your Assets folder if it exist.

    (Note it is just my guessing. I'm not sure whether you have the splashscreen because I cannot reproduce.)

    But after you have done this you have to package your app again by refer to here https://msdn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-manual-conversion It is because we need to sign our package again. Maybe we also need to use that makepri command to re-generate the resource.

    Anyway, the above is a possible solution if you have splashscreen in your app manifest.

    If it does not work maybe you can try the first way. To test whether it works I think you can put one of your method in the sample project's Win32 service and see if you can successfully use it.  

    Best regards,

    Barry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    2016年12月8日 14:21
    版主
  • Good job, I will try your method in the future, thank you for your reply.
    • 已编辑 lc-soft 2016年12月8日 15:21 update
    2016年12月8日 15:19