Ejemplo n.º 1
0
        public static string GetProcess32File(ProcessEntry32 lpProcess)
        {
            int           nSize         = 1024;
            StringBuilder stringBuilder = new StringBuilder(1024);
            IntPtr        intPtr        = Process32.OpenProcess(Process32.PROCESS_QUERY_INFORMATION | Process32.PROCESS_VM_READ, 0, lpProcess.th32ProcessID);

            Process32.GetModuleFileNameEx(intPtr, IntPtr.Zero, stringBuilder, 1024);
            if (stringBuilder.Length == 0)
            {
                Process32.GetProcessImageFileName(intPtr, stringBuilder, nSize);
            }
            Process32.CloseHandle(intPtr);
            return(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        public static string GetProcess32File(ProcessEntry32 lpProcess)
        {
            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(260);
            System.IntPtr             intPtr        = Process32.OpenProcess(Process32.PROCESS_QUERY_INFORMATION | Process32.PROCESS_VM_READ, 0, lpProcess.th32ProcessID);
            Process32.GetModuleFileNameEx(intPtr, System.IntPtr.Zero, stringBuilder, 260);
            if (stringBuilder.Length == 0)
            {
                Process32.GetProcessImageFileName(intPtr, stringBuilder, 260);
            }
            Process32.CloseHandle(intPtr);
            string text = stringBuilder.ToString();

            if (text.Contains("\\Device\\HardDiskVolume", true))
            {
                string[] logicalDrives = System.IO.Directory.GetLogicalDrives();
                for (int i = 0; i < logicalDrives.Length; i++)
                {
                    text = text.Replace("\\Device\\HarddiskVolume" + (i + 1) + "\\", logicalDrives[i]);
                }
            }
            return(text);
        }