使用UWP打开Runfulltrust Desktop应用程序打破桌面应用程序

发布于 2025-01-23 10:58:51 字数 1575 浏览 0 评论 0原文

这确实没有任何意义。我有一个UWP应用程序,标题为firstUWP。它自己打开了。

我有一个称为scrren.exe的桌面扩展程序,利用Tesseract从屏幕上读取一些图像。首先打开我的UWP,然后单独打开scrren.exe,都可以正常运行。

但是,当我使用UWP的Runfulltrust启动器时,scrren.exe无法写入UWP项目下的文件。

当它们完全单独启动时,scrren.exe可以写入文件夹,而当UWP启动它scrren.exe无法写入文件夹中时UWP。

该代码是桌面扩展中发生问题的地方sccren.exe。我还附加了一个屏幕截图,显示了UWP中的资产树,显示了我的问题起源的图像文件夹。在此之下,我附加了一个屏幕截图,显示了我的意思是,当从UWP中启动时,scrren.exe显示在UWPS父母名称下,但这是我得到错误的地方,scrren.exe.exe.exe无法写入图像文件夹。

我真的希望这是有道理的。

string result = Assembly.GetExecutingAssembly().Location;
int index = result.LastIndexOf("\\");
string rootPath = $"{result.Substring(0, index)}\\..\\";

using (Bitmap bitmap1 = new Bitmap(bounds.Width, bounds.Height))
{
    using (Graphics g = Graphics.FromImage(bitmap1))
    {
        g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
    }

    try
    {
        using (bitmap1)
        {
            bitmap1.Save((rootPath + @"Scrn\Images\test.png"), System.Drawing.Imaging.ImageFormat.Png);
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message + "Right here");
    }

    // Sleep for one second in order to let the file properly save
    Thread.Sleep(1000);
}

” ://i.sstatic.net/ulvo5.png“ alt =”在此处输入图像说明”>

This really does not make any sense. I have a UWP application, titled FirstUWP. It opens fine on its own.

I have a desktop extension that I made called scrren.exe, taking advantage of tesseract to read some image from the screen. When first opening my UWP and then opening up the scrren.exe on it's own, both run fine.

However, when I use the runfulltrust launcher from UWP, the scrren.exe cannot write to a file that is under the UWP's project.

When they are launched entirely separately, the scrren.exe can write to the folder fine, it is just when the UWP launches it the scrren.exe cannot write to the folder within the UWP.

This code is the place where the problem occurs within the Desktop Extension sccren.exe. I've also attached a screenshot showing the Assets tree within the UWP, showing the Images folder which seems to be where my problems originate. Below that, I attached a screenshot showing what I mean that when launched from within UWP, scrren.exe shows up under the UWPs parent name, but this is where I get errors and scrren.exe cannot write to the Images folder.

I really hope this makes sense.

string result = Assembly.GetExecutingAssembly().Location;
int index = result.LastIndexOf("\\");
string rootPath = 
quot;{result.Substring(0, index)}\\..\\";

using (Bitmap bitmap1 = new Bitmap(bounds.Width, bounds.Height))
{
    using (Graphics g = Graphics.FromImage(bitmap1))
    {
        g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
    }

    try
    {
        using (bitmap1)
        {
            bitmap1.Save((rootPath + @"Scrn\Images\test.png"), System.Drawing.Imaging.ImageFormat.Png);
        }
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message + "Right here");
    }

    // Sleep for one second in order to let the file properly save
    Thread.Sleep(1000);
}

This image shows my asset tree within the UWP, including the Images folder

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后来的我们 2025-01-30 10:58:51

您无法写入包装应用程序的安装位置;它是只读的。相反,您应该使用 applicationdata.current.localfolder 获取用于保存文件的本地文件夹。

另外,请确保您正在使用 full tr​​ustProcessLauncher 启动您的EXE,而不是process.start()

You can't write to a packaged app's install location; it is read-only. Instead you should be using ApplicationData.Current.LocalFolder to get the local folder for saving files.

Also make sure you are using FullTrustProcessLauncher to launch your exe, not something like Process.Start().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文