Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
1) We call the sports lotto so that you can connect the free google service;
2) Go to https://google.com and write a simple request "c# find out the parameters of the running application"
3) Follow the first link: Getting information from the "Command line" column...
4) ctrl+c and ctrl+v:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Management;
namespace ConsoleApplication7 {
class Program {
static void Main(string[] args) {
Process[] processList = Process.GetProcesses();
Process p = processList.Where(temp => temp.Id == 844).FirstOrDefault();
if (p != null) {
GetCommandLine(p.Id);
}
Console.ReadLine();
}
public static void GetCommandLine(int id) {
using (ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + id)) {
foreach (ManagementObject mo in mos.Get()) {
Console.WriteLine(mo["CommandLine"]);
}
}
}
}
}
private static string GetCommandLine(this Process process)
{
using (ManagementObjectCollection objects = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id).Get())
{
return objects.Cast<ManagementBaseObject>().SingleOrDefault()?["CommandLine"]?.ToString();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question