我正在尝试让我的应用程序确定用户系统上是否安装了 Microsoft Visual C++ 2013 Redistributable。我已经浏览了此处、此处和此处的答案,但看起来所有答案都分为两大类:
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall,HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\VC和HKLM\SOFTWARE\Wow6432Node\Microsoft\DevDiv\VC。wmic product get或检查系统表new ManagementObjectSearcher("SELECT * FROM Win32_Product")。这是可靠的,但非常慢(40 秒以上),因为它看起来必须在返回结果之前加载系统上安装的所有产品。当可再发行安装程序运行时,安装程序能够非常快速地确定组件是否已安装:
或未安装:
什么是最快的方法来做到这一点仍然可靠?理想情况下,我想知道:微软是怎么做到这么快的?我可以那样做吗?
我有很多这样的控制器:
public class EntityController : Controller
{
private readonly IEntityRepository _entity;
public EntityController(IEntityRepository entity)
{
_entity = entity;
}
[Authorize]
[HttpPut("{id}")]
public async ValueTask<IActionResult> Put(int id, [FromBody] Entity entity)
{
if (entity == null || entity.Id != id) return BadRequest();
var updated = await _entity.Update(entity);
if (updated == null) return NotFound();
return Ok(updated);
}
}
Run Code Online (Sandbox Code Playgroud)
我需要实现实体编辑(审计)历史。
而且,由于该方法被标记为[Authorize],我需要记录它是由哪个用户编辑的。我正在看Audit.NET,但我没有找到方法来做到这一点。