# Listing program in Window Title Bar

**URL:** <https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086>\
**Category:** Factual Questions\
**Created:** [August 12, 2013, 11:46pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086 "2013-08-12T23:46:48Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Don\_t\_Call\_Me\_Shirley](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@Don\_t\_Call\_Me\_Shirley](https://boards.straightdope.com/u/Don_t_Call_Me_Shirley)\
**Post date:** [August 12, 2013, 11:46pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/1 "2013-08-12T23:46:48Z")

</div>

On my computer, running Windows 7, the title bars of the windows list the open file and then the program name, ie: “Book1 - Microsoft Excel”. Other users in my office, that seemingly have the same setup as me, only have the file name, ie: “Book1.” I am writing some Windows API and I need to have everyone list the program name in the title bar so I can find the window handle.

There must be some setting in Windows that I’m overlooking, but I can’t find it anywhere. I have Googled this to death and can’t find anything. Does anyone know where the setting for this is?

Thanks!

---

<div class="post-metadata">

**Author:** ![dstarfire](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/dstarfire/32/5762_2.png) [@dstarfire](https://boards.straightdope.com/u/dstarfire)\
**Post date:** [August 13, 2013, 6:41pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/2 "2013-08-13T18:41:56Z")

</div>

I’d suspect it’s a setting in Excel itself that does this. I’ve used a variety of text editors over the years that include options to hide the current file’s path in the title bar (so you don’t have something like “notepad - c:/users/username/documents/simson/meetings/2013/springs sales.txt” trying to show).

---

<div class="post-metadata">

**Author:** ![Blakeyrat](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Blakeyrat](https://boards.straightdope.com/u/Blakeyrat)\
**Post date:** [August 13, 2013, 7:26pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/3 "2013-08-13T19:26:14Z")

</div>

I don’t know what you mean by “writing some Windows API” (didn’t Microsoft already do that? 🙂 ) but I’d wager there’s a better way to do what you want to do. Window titles can change for literally any reason (most commonly being localization-- what do you think “book1” reads if you’re in Russia?) and if you write code assuming the window title will look a certain way, it’ll be fragile and require constant maintenance.

Assuming you’re talking about Excel specifically, Microsoft has released a [library to do Office interop](http://msdn.microsoft.com/en-us/library/dd264733.aspx), which should be a much better fit what you’re you’re trying to do and will be guaranteed to call into Excel using the correct window messages and not break based on localization settings or future changes to Excel.

I could give you a better answer if you tell me exactly what it is you want to accomplish.

---

<div class="post-metadata">

**Author:** ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)\
**Post date:** [August 14, 2013, 12:19am UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/4 "2013-08-14T00:19:44Z")

</div>

You could look for process name or window class (or parent window class). [http://support.microsoft.com/kb/112649](http://support.microsoft.com/kb/112649)

---

<div class="post-metadata">

**Author:** ![Don\_t\_Call\_Me\_Shirley](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@Don\_t\_Call\_Me\_Shirley](https://boards.straightdope.com/u/Don_t_Call_Me_Shirley)\
**Post date:** [August 14, 2013, 2:30pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/5 "2013-08-14T14:30:24Z")

</div>

> [@Blakeyrat](#):
>
> I don’t know what you mean by “writing some Windows API” (didn’t Microsoft already do that? 🙂 ) but I’d wager there’s a better way to do what you want to do. Window titles can change for literally any reason (most commonly being localization-- what do you think “book1” reads if you’re in Russia?) and if you write code assuming the window title will look a certain way, it’ll be fragile and require constant maintenance.
> 
> Assuming you’re talking about Excel specifically, Microsoft has released a [library to do Office interop](http://msdn.microsoft.com/en-us/library/dd264733.aspx), which should be a much better fit what you’re you’re trying to do and will be guaranteed to call into Excel using the correct window messages and not break based on localization settings or future changes to Excel.
> 
> I could give you a better answer if you tell me exactly what it is you want to accomplish.

Unfortunately, I am not talking about Excel, I just used that as an example. My code makes Excel interface with a BS third-party application that I am forced to use against my will. That application changes titles all the time, but on my machine, the title always contains the program name, so I can always find it regardless of the rest of the title. But on some other machines, the program name is not included in the title bar, so my code doesn’t work. I would love it if there was another way, I’m going to look through that page that Reply linked to as well.

What I am doing in a nutshell is taking data from Excel and entering it into the BS third-party software. It’s been running like clockwork on my machine for over a year, so I’d rather not make drastic changes. I understand what you’re saying about there being an easier way, but just getting that program name in the title bar will solve the problem for now.

---

<div class="post-metadata">

**Author:** ![Blakeyrat](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@Blakeyrat](https://boards.straightdope.com/u/Blakeyrat)\
**Post date:** [August 14, 2013, 5:27pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/6 "2013-08-14T17:27:24Z")

</div>

If it were me (and assuming the other program has no API or scripting interface), I’d tell my management it can’t be done in a reasonable way and find an alternative. Frankly.

Good luck.

---

<div class="post-metadata">

**Author:** ![Don\_t\_Call\_Me\_Shirley](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@Don\_t\_Call\_Me\_Shirley](https://boards.straightdope.com/u/Don_t_Call_Me_Shirley)\
**Post date:** [August 16, 2013, 12:10pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/7 "2013-08-16T12:10:31Z")

</div>

I’m really surprised there isn’t an easy answer to this. I thought there would be a box to check somewhere, or maybe a registry setting that would be easy to find. When I google it I can’t even find anyone else asking this question.

I guess I’ll write a loop that looks through the possible titles (there are five or six that should cover 99% of the cases) and keeps looking until it finds a handle that isn’t 0. Unless anyone else has a better idea.

Thanks for the suggestions everyone.

---

<div class="post-metadata">

**Author:** ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)\
**Post date:** [August 16, 2013, 1:14pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/8 "2013-08-16T13:14:33Z")

</div>

Did you look into the process names and window classes? Those are better ways to identify apps.

---

<div class="post-metadata">

**Author:** ![Don\_t\_Call\_Me\_Shirley](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@Don\_t\_Call\_Me\_Shirley](https://boards.straightdope.com/u/Don_t_Call_Me_Shirley)\
**Post date:** [August 17, 2013, 4:41pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/9 "2013-08-17T16:41:32Z")

</div>

> [@Reply](#):
>
> Did you look into the process names and window classes? Those are better ways to identify apps.

I’m definitely going to look into it. If you have any tips or a link to a good website that explains it I would appreciate it. It sounds a lot better than what I’m doing now.

---

<div class="post-metadata">

**Author:** ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)\
**Post date:** [August 19, 2013, 4:05am UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/10 "2013-08-19T04:05:42Z")

</div>

> [@Don\_t\_Call\_Me\_Shirley](#):
>
> I’m definitely going to look into it. If you have any tips or a link to a good website that explains it I would appreciate it. It sounds a lot better than what I’m doing now.

What language are you working with?

---

<div class="post-metadata">

**Author:** ![Don\_t\_Call\_Me\_Shirley](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@Don\_t\_Call\_Me\_Shirley](https://boards.straightdope.com/u/Don_t_Call_Me_Shirley)\
**Post date:** [August 19, 2013, 2:53pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/11 "2013-08-19T14:53:10Z")

</div>

> [@Reply](#):
>
> What language are you working with?

Visual Basic.

---

<div class="post-metadata">

**Author:** ![Space\_Vegetable](https://avatars.discourse-cdn.com/v4/letter/s/6de8d8/32.png) [@Space\_Vegetable](https://boards.straightdope.com/u/Space_Vegetable)\
**Post date:** [August 19, 2013, 8:30pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/12 "2013-08-19T20:30:45Z")

</div>

As far as I know, every program decides on its own what text should go in its title bar. Windows doesn’t control this though any system-wide setting that I’m aware of.

So a program could decide to include its name, or not, based on the version of Windows, the current screen resolution, or whether the name of the current month includes an R.

Here’s another Microsoft article that may help: [How To Get a Window Handle Without Specifying an Exact Title](http://support.microsoft.com/kb/147659). This one, like the one posted earlier, is for VB versions 4-6, all pretty old, but perhaps that’s what you’re using.

---

<div class="post-metadata">

**Author:** ![Reply](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/reply/32/15952_2.png) [@Reply](https://boards.straightdope.com/u/Reply)\
**Post date:** [August 20, 2013, 5:36am UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/13 "2013-08-20T05:36:18Z")

</div>

> [@Don\_t\_Call\_Me\_Shirley](#):
>
> Visual Basic.

In [VB.net](http://VB.net): [FAQ Item: How to retrieve a Window Handle in Visual Basic.NET? | Microsoft Learn](http://social.msdn.microsoft.com/Forums/vstudio/en-US/f06d1530-553c-432e-a25d-376031b80912/faq-item-how-to-retrieve-a-window-handle-in-visual-basicnet)

For other versions, just Google “visual basic (whatever version) window handles”

---

<div class="post-metadata">

**Author:** ![Don\_t\_Call\_Me\_Shirley](https://avatars.discourse-cdn.com/v4/letter/d/f4b2a3/32.png) [@Don\_t\_Call\_Me\_Shirley](https://boards.straightdope.com/u/Don_t_Call_Me_Shirley)\
**Post date:** [August 21, 2013, 10:49pm UTC](https://boards.straightdope.com/t/listing-program-in-window-title-bar/666086/14 "2013-08-21T22:49:11Z")

</div>

> [@Reply](#):
>
> In [VB.net](http://VB.net): [FAQ Item: How to retrieve a Window Handle in Visual Basic.NET? | Microsoft Learn](http://social.msdn.microsoft.com/Forums/vstudio/en-US/f06d1530-553c-432e-a25d-376031b80912/faq-item-how-to-retrieve-a-window-handle-in-visual-basicnet)
> 
> For other versions, just Google “visual basic (whatever version) window handles”

I’m not finding anything I can use. Everything I am finding talks about starting a new proess and then getting that process ID. I need to get a process ID of a program that is already running.
