在 .NET 中进行模拟时如何获取应用程序的名称。我对您喜欢 VB.NET 或 C# 的 .NET 语言没有任何偏好。我本质上是在做(这里请原谅 VB.NET):
theImpersonator = New Impersonator("username", "domain", "password")
Dim finfo As New FileInfo(Process.GetCurrentProcess().MainModule.FileName)
Dim appname As String = finfo.Name.Substring(0, finfo.Name.IndexOf("."))
不使用“New Impersonator(...)”一切都很好。当我使用“模仿者”时,我得到:
Access is denied
at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32 access, Boolean throwIfExited)
at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
at System.Diagnostics.Process.get_MainModule()
使用模拟时如何找出我的应用程序 .exe 文件的名称?