sskarnik
sskarnik

Reputation: 21

How do I change name of a process on task manager in C++?

I have a process with name as "processName" and executable as "processName.exe". I want to launch this process and change name of the process of how it appears in task manager. I can not just rename the executable because I want to have space in name. For example it should look like "ProcessName somethingelse" in task manager. I can see some programs doing this, for example for command prompt executable name is "cmd.exe" but name on command prompt is "Windows Command Processor" which has space in it's name.

Upvotes: 1

Views: 5911

Answers (1)

Ted Lyngmo
Ted Lyngmo

Reputation: 117298

The application/task name is the title of the main window (a chapter of its own). You can change your own title using SetWindowText:

BOOL SetWindowTextA( // Ansistring version
  HWND   hWnd,       // handle to your main window
  LPCSTR lpString    // new name
);

or

BOOL SetWindowTextW( // Widestring version
  HWND    hWnd,
  LPCWSTR lpString
);

Upvotes: 2

Related Questions