Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# get process file location

public static string GetProcessPath(int processId)
{
    string MethodResult = "";
    try
    {
        string Query = "SELECT ExecutablePath FROM Win32_Process WHERE ProcessId = " + processId;

        using (ManagementObjectSearcher mos = new ManagementObjectSearcher(Query))
        {
            using (ManagementObjectCollection moc = mos.Get())
            {
                string ExecutablePath = (from mo in moc.Cast<ManagementObject>() select mo["ExecutablePath"]).First().ToString();

                MethodResult = ExecutablePath;

            }

        }

    }
    catch //(Exception ex)
    {
        //ex.HandleException();
    }
    return MethodResult;
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: C# setting property values through reflection with attributes 
Csharp :: how to find the tag of an objecdt in unity 
Csharp :: how to get row index of selected row in gridview asp.net webforms 
Csharp :: c# binary search 
Csharp :: power of number 
Csharp :: Read a Word Document Using C# 
Csharp :: c# string ends with 
Csharp :: from string 
Csharp :: c# get serial ports 
Csharp :: msbuild publish to folder command line .net 
Csharp :: how to insert into a list c# 
Csharp :: remove force unity 
Csharp :: get all classes that extend a class c# 
Csharp :: To CharArray 
Csharp :: get last index C# 
Csharp :: returning multiple values in C# 
Csharp :: scale between tow ranges c# 
Csharp :: group by unique c# 
Csharp :: wpf how to focus on element 
Csharp :: c# draw rectangle on screen 
Csharp :: C# api get value from header 
Csharp :: c# datagridview double click on cell 
Csharp :: migrationbuilder insert data example 
Csharp :: System.Data.Entity.Core.EntityException: The underlying provider failed on Open 
Csharp :: unity singleton 
Csharp :: finding keys in the registry 
Csharp :: how to decrease velocity of a Unity rigidbody 
Csharp :: c# generic return type in interface 
Csharp :: csharp Console.Read(); 
Csharp :: Why Duplicate "..TargetFrameworkAttribute" c# assemblies created 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =