我需要使用C#模拟用户.我使用LogonUser Win32 API.当模拟与当前登录用户相同的域中的用户时,此方法可以正常工作.但是,当我尝试冒充其他域中的用户时,我会收到"false"作为响应.
是什么导致这个?
我正在尝试开发一个应用程序,它将从我的PC监视位于服务器上的进程的内存使用情况.我创建了一个应用程序,它将监视位于运行应用程序的同一台PC上的进程的内存使用情况,但无法弄清楚如何从我的PC运行应用程序并监视另一台PC的/服务器进程.
任何帮助都会让我指向正确的道路.
UPDATE
这是我到目前为止:
private static string sProcName = "PCMain";
private static string machine = "serverName";
private static int sProcMemoryInKB = 10000;
static void Main(string[] args) {
VerifyRemoteMachineStatus(machine);
GetMachineName();
Process ReqProcess;
GC.GetTotalMemory(true);
ReqProcess = CurrentlyRunning(sProcName);
do {
if (ReqProcess != null) {
System.Threading.Thread.Sleep(1000);
// calculate the CPU load
System.TimeSpan CPULoad = (DateTime.Now - ReqProcess.StartTime);
Console.WriteLine("CPU Load: " + (ReqProcess.TotalProcessorTime.TotalMilliseconds / CPULoad.TotalMilliseconds) * 100);
PerformanceCounter WorkingSetMemoryCounter = new PerformanceCounter("Process", "Working Set", sProcName, machine);
//System.Threading.Thread.Sleep(1000);
Console.WriteLine("Momory (Working Set) " + (WorkingSetMemoryCounter.NextValue() / …Run Code Online (Sandbox Code Playgroud)