Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a process window class name from c#?

Tags:

c#

process

How can I get the window class name of a certain process? I want to achieve this in c#.

I've tried the process class in c# but I can only get the window name of the process.

Thanks

like image 739
Jax Avatar asked Oct 27 '25 04:10

Jax


1 Answers

I assume you mean you want to get the class name of the main window of a process.

To do this, you will need to get the handle to the main window using the MainWindowHandle of your Process object, and then use the following interop method to obtain the class name:

[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern int GetClassName(IntPtr hWnd, StringBuilder lpClassName, int nMaxCount);

see pinvoke.net for sample code and MSDN for details on the function.

like image 173
Rotem Avatar answered Oct 28 '25 16:10

Rotem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!