C/C++ has always been a pain when it comes to GUI but there are several ways to create them via API in a easy way. when you need your GUI to be fancy you have to deal with few things in windows... first is to create a form then by using the SetLayeredWindow api you can transform that form into a layer by passing the hwnd of the window. once you get your layer ready you can use GDI+ to draw everything you need. there are also DX ways to do that but they are too complicated.how much do you know of win32 window creation? my main thing was i could almost never get my code to create addition windows right, i could make them but when i closed one it closed everything down, i fixed it once but i broke it and never got it working again :/. than again with everything i learned from c#, if i went back now and tried, i most likely could get it easily lol. learning c# helped me learn aspects of coding that i found rather difficult in c++ and was able to learn those a lot easier, i wonder if i could code much more efficiently in c++ now lol.
private void button1_Click(object sender, EventArgs e)
{
Process[] procs = Process.GetProcesses(Environment.MachineName);
foreach (Process process in procs)
listBox1.Items.Add(process.ProcessName);
}
lol that´s quite easy.. for that you are going to need the modules on each process... the processname.modules have a collection of modules of type "ProcessModule" you can use it like that:Lol rauntec.I know what I need to do to get the current processes.The thing I don't know is WHAT I need to do to get the extension for EACH process.This code that I gave here shows the current processes like for example "notepad"....blablabla.What I want to do is how to show the EACH process extension,for example--->"notepad.exe"<---You can here see the EXE extension.
So how to display the extension for EACH process??????![]()
private void button1_Click(object sender, EventArgs e)
{
Process[] procs = Process.GetProcesses(".");
foreach (Process process in procs)
{
try
{
foreach (ProcessModule modul in process.Modules)
{
listBox1.Items.Add(modul.ModuleName);
//Here some more in case you need them
//modul.FileName;
//modul.ModuleMemorySize.ToString();
//modul.FileVersionInfo.FileVersion;
}
}
catch { }
}
}
lol you have wishesThat does shows the extensions,but it's not showing my currently active processes like WMP and so on...lol.
private void button1_Click(object sender, EventArgs e)
{
Process[] procs = Process.GetProcesses(".");
foreach (Process process in procs)
{
try
{
if (process.MainWindowTitle.Length > 0)
{
listBox1.Items.Add(process.MainModule.ModuleName);
//foreach (ProcessModule modul in process.Modules)
//{
// listBox1.Items.Add(modul.ModuleName);
// //Here some more in case you need them
// //modul.FileName + Environment.NewLine;
// //modul.ModuleMemorySize.ToString();
// //modul.FileVersionInfo.FileVersion;
//}
}
}
catch { }
}
}
Try
{
//Your code
}
Catch{}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace process
{
public partial class Form1 : Form
{
/*API Declarations*/
[DllImport("user32.dll")]
public static extern int FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
private const int WM_SYSCOMMAND = 0x0112;
private const int SC_CLOSE = 0xF060;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listProcs();
}
private void listProcs()
{
Process[] procs = Process.GetProcesses(Environment.MachineName);
listBox1.Items.Clear();
foreach (Process process in procs)
{
try
{
if (process.MainWindowTitle.Length > 0)
{
listBox1.Items.Add(process.MainModule.ModuleName + " - " + process.MainWindowHandle);
//foreach (ProcessModule modul in process.Modules)
//{
// listBox1.Items.Add(modul.ModuleName);
// //Here some more in case you need them
// //modul.FileName + Environment.NewLine;
// //modul.ModuleMemorySize.ToString();
// //modul.FileVersionInfo.FileVersion;
//}
}
}
catch { }
}
}
private void listBox1_KeyUp(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Delete && listBox1.SelectedItem != null && listBox1.SelectedItem.ToString().Length > 0)
{
int ihandle = Convert.ToInt32(listBox1.SelectedItem.ToString().Split('-')[1].Trim());
SendMessage(ihandle, WM_SYSCOMMAND, SC_CLOSE, 0);
listProcs();
}
}
}
}
int iHandle = FindWindow("wmplayer", "Windows Media Player");
if (iHandle > 0)
{
// close the window using API
SendMessage(iHandle, WM_SYSCOMMAND, SC_CLOSE, 0);
}