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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With