Click here to Skip to main content
15,867,141 members
Articles / Programming Languages / C++
Article

PathBreaker - WTL utility to easily edit PATH-like strings

Rate me:
Please Sign up or sign in to vote.
4.38/5 (14 votes)
6 Jul 2004CPOL 54.9K   1.3K   31   8
Editing environment strings like PATH, INCLUDE and LIB is painful? Not anymore.

Sample Image - imgPathBreaker.gif

The Tool

PathBreaker is a small WTL application where you can paste (or enter) a multiple path string (like the PATH environment variable), and edit the individual paths.

When toying around with the batch build of a larger application, I was incredibly annoyed by the editing of environment strings, like the PATH or INCLUDE variable. Visual Studio provides a nice interface for its internal strings, but nothing that works stand-alone.

I figured this would make a nice standalone WTL application - and here it is. No installation is necessary, and the executable is just 40K.

The Source code

Source code is included for anyone interested. It uses WTL 7 (which is now OpenSource - see SourceForge), but should work with previous WTL versions as well. Things that might be interesting are:

  • Browsing for a folder using SHBrowseForFolder.
  • Setting the initial folder when using SHBrowseForFolder.
  • Building a popup menu dynamically.
  • Enumerating Environment variables.
  • Editing the labels in a list control.
  • Entering Label Edit using the keyboard (F", or just start typing).
  • Copying / Pasting CString to / from clipboard.

If you like it - fine!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Klippel
Germany Germany
Peter is tired of being called "Mr. Chen", even so certain individuals insist on it. No, he's not chinese.

Peter has seen lots of boxes you youngsters wouldn't even accept as calculators. He is proud of having visited the insides of a 16 Bit Machine.

In his spare time he ponders new ways of turning groceries into biohazards, or tries to coax South American officials to add some stamps to his passport.

Beyond these trivialities Peter works for Klippel[^], a small german company that wants to make mankind happier by selling them novel loudspeaker measurement equipment.


Where are you from?[^]



Please, if you are using one of my articles for anything, just leave me a comment. Seeing that this stuff is actually useful to someone is what keeps me posting and updating them.
Should you happen to not like it, tell me, too

Comments and Discussions

 
GeneralPretty good. Couple of comments.... Pin
prcarp12-Jul-04 3:07
prcarp12-Jul-04 3:07 
First, I liked your code as I am just learning WTL. Your code provides some good examples.

As far as the functionality of the program, I just have a couple of things to note:

1) The link for the executable didn't work (codeproject error?). The source downloaded and compiled fine.

2) The first time I ran it, the edit field and list box were full of garbage characters, perhaps a leftover from the clipboard from another program. Couldn't repeat the problem though.

3) You acquire the environment variables through the GetEnvironmentStrings() call which is fine for getting the combined User and System variables. However, how would keep them straight when addressing issue #4...

4) The program did not appear to save the environment variables. I saw a //TODO on the dialog's OnOK method so I am guessing that will be left up to us. But if user and system environments become mixed (issue #3), then this will be very tough. Am I missing something?

Anyway, good example code from a WTL newbie perspective...

-Paul
GeneralRe: Pretty good. Couple of comments.... Pin
peterchen12-Jul-04 5:44
peterchen12-Jul-04 5:44 
GeneralRe: Pretty good. Couple of comments.... Pin
prcarp12-Jul-04 9:36
prcarp12-Jul-04 9:36 
GeneralRe: Pretty good. Couple of comments.... Pin
prcarp12-Jul-04 9:39
prcarp12-Jul-04 9:39 
GeneralRe: Pretty good. Couple of comments.... Pin
David Pritchard8-Oct-04 4:15
David Pritchard8-Oct-04 4:15 
GeneralRe: Pretty good. Couple of comments.... Pin
peterchen8-Oct-04 5:59
peterchen8-Oct-04 5:59 
GeneralRe: Pretty good. Couple of comments.... Pin
prcarp11-Oct-04 7:19
prcarp11-Oct-04 7:19 
GeneralRe: Pretty good. Couple of comments.... Pin
David Pritchard11-Oct-04 9:12
David Pritchard11-Oct-04 9:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.