在受保护模式下确定虚拟化文件位置 [英] Determining virtualized file location when in protected mode

查看:167
本文介绍了在受保护模式下确定虚拟化文件位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些插件/扩展/ activex控件,无论你想要什么,我在网页中使用对象标签引用。它们是用C#编写的。 IE在Vista上以受保护模式运行。这些activex控件需要写入本地文件系统。例如,在一种情况下,这些文件是用户通过单击我们提供的"快照"按钮拍摄的网页的快照。我们使用Image.Save()方法将这些文件(具有唯一名称)放置到FOLDERID_Pictures文件夹中,然后通过状态向用户指示我们刚刚为它们保存的文件的路径名。这样,用户可以快速拍摄多个快照,而无需为每个快照"确定""另存为..."对话框。这在XP下成功运作。它在Vista下工作正常,因为文件保存在C:\ Users \ testuser \ AppData \ Local \ Microsoft \ Windows \ Temporary Internet Files \ Virtualized \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\图片。

如何确定文件的保存位置,以便我们向用户报告位置?我已经尝试过Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),IEGetWriteableFolderPath和SHGetKnownFolderPath。 SHGetKnownFolderPath和Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)总是返回c:\ Users \ testuser \Pictures作为路径名,当我们调用Image.Save()提供返回的路径名时,它进入虚拟化目录。调用IEGetWriteableFolderPath会返回E_ACCESSDENIED。所以我想这会告诉我们一些事情,我们不能把它放在我们想要的地方。但是当我传递FOLDERID_LocalAppDataLow时IEGetWriteableFolderPath也返回E_ACCESSDENIED但是当我用该GUID调用SHGetKnownFolderPath并将Image.Save调用到该文件夹​​时,它可以工作。所以我甚至不能信任IEGetWriteableFolderPath。

有人可以帮帮我吗?在我看来,有一种方法可以向Vista询问已知文件管理系统虚拟化的路径名,但是当我搜索MSDN或Google时,我找不到任何内容。我发现很难相信MS希望其开发人员硬编码像"C:\ Users \ testuser \ AppData \ Local \ Microsoft \ Windows \ Temporary Internet Files \ Virtualized \\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\Users\testuser\Pictures"在其代码中。 IEGetWriteableFolderPath肯定对我来说是正确的。有没有其他人让它适用于任何预定义的FOLDERID?

任何帮助表示赞赏。

谢谢,
--Aaron

解决方案

IE7上引入的IE保护模式导致IE进程为低IL(完整性等级)(Windows Vista / Windows 7功能)。对于此完整性级别,有一些访问用户资源的规则(文件系统和注册表)。

使用保护模式关闭,您可以像在Windows XP中一样访问所有用户资源。
所以你可以将保护模式设置为关闭以管理员身份运行IE或访问区域"可信站点"上的站点。

在IE8保护模式下,默认情况下也为Intranet区域关闭。

教您的用户将您的域添加到可信站点列表,它将正常工作。

在IE7上将需要两个IE实例来运行受保护和不受保护的站点。在IE8选项卡上可以使用不同的IL(PM off / PM on)共享相同的帧事件。

有关详细信息,请参阅:

了解并在保护模式下工作Internet Explorer
http://msdn.microsoft.com /en-us/library/bb250462(VS.85).aspx


Windows Vista完整性机制技术参考
http://msdn.microsoft.com/en-us/库/ bb625964.aspx


I have some plugins/extensions/activex controls, whatever you want to call them, that I reference using object tags in web pages.  They are written in C#.  IE is running in protected mode on Vista.  These activex controls need to write to the local file system.  For example, in one case, these files are snapshots of the web page that the user took by clicking on a 'snapshot' button we present.  We are placing (with unique names) these files to the FOLDERID_Pictures folder using the Image.Save() method and then via status indicating to the user the pathname of the file we just saved for them.  This way the user can take multiple snapshots, perhaps quickly, without having to 'ok' a 'Save As...' dialog for each one.  This was successfully working under XP.  It works fine under Vista thought the file gets saved in C:\Users\testuser\AppData\Local\Microsoft\Windows\Temporary Internet Files\Virtualized\C\Users\testuser\Pictures.

How can I determine where the file is going to get saved so that we can report the location to the user?  I've tried Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), IEGetWriteableFolderPath and SHGetKnownFolderPath.  SHGetKnownFolderPath and Environment.GetFolderPath(Environment.SpecialFolder.MyPictures) always return c:\Users\testuser\Pictures as the pathname yet when we call Image.Save() providing that returned pathname, it goes in the virtualized directory.  Calling IEGetWriteableFolderPath returns E_ACCESSDENIED.  So I guess that tells us something, that we can't put it where we want.  But IEGetWriteableFolderPath also returns E_ACCESSDENIED when I pass FOLDERID_LocalAppDataLow yet when I call SHGetKnownFolderPath with that GUID and call Image.Save to that folder, it works.  So I can't really even trust IEGetWriteableFolderPath.

Can someone help me?  It seems to me that there HAS to be a way to ask Vista what pathname a known folderid is getting virtualized to, but I can't find anything when I search MSDN or Google.  I find it hard to believe that MS expects its developers to hardcode a path like "C:\Users\testuser\AppData\Local\Microsoft\Windows\Temporary Internet Files\Virtualized\C\Users\testuser\Pictures" in its code.  IEGetWriteableFolderPath sure seems like the right call to me.  Has anyone else got it to work for any of the pre-defined FOLDERID's?

Any help appreciated.

Thanks,
--Aaron

解决方案

IE Protected Mode introduced on IE7 causes the IE process as LOW IL (Integrity Level) (Windows Vista/Windows 7 feature). For this Integrity Level there are some rules for accessing the user resources (file system and registry).

With Protected Mode Off you can access all user resources normally as in Windows XP.
So you can set protected mode to Off running IE as Administrator or accessing sites on zone "Trusted Sites".

In IE8 protected mode is Off by default for the Intranet Zone too.

Teach your users to add your domain to Trusted Sites list and it will work fine.

On IE7 will be necessary two Instances of IE to run protected and unprotected sites. On IE8 tabs can share the same frame event using different ILs (PM off/PM on).

For further information see:

Understanding and Working in Protected Mode Internet Explorer
http://msdn.microsoft.com/en-us/library/bb250462(VS.85).aspx

Windows Vista Integrity Mechanism Technical Reference
http://msdn.microsoft.com/en-us/library/bb625964.aspx


这篇关于在受保护模式下确定虚拟化文件位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆