1 message in com.perforce.perforce-user[p4] Re: P4 commands from Windows Exp...
FromSent OnAttachments
Neal Firth26 Feb 2002 10:49 
Subject:[p4] Re: P4 commands from Windows Explorer
From:Neal Firth (Neal@buildmeisters.com)
Date:02/26/2002 10:49:19 AM
List:com.perforce.perforce-user

Can you explain how to do this? We have some people who will soon be using
Perforce and who are currently accustomed to working in Windows Explorer. P4WIN
would be overwhelming for their needs. If I can just add a few custom P4 menu
items to Explorer, that would do the trick for them.

Michael,

The information in Dirk?s email is certainly correct and a good solution to the
general problem of accessing p4 from the shell. But, as it turns out, you can
also extend the Windows explorer without doing a full plug in (but usability is
an issue ? see below). The exact mechanisms are documented in several places.
The easiest source is MSN under the topic of ?Extending the Shell?. You can also
search for ?Shell FAQ? and start reading from the top. Beware that this
documentation is great if you already know what you?re doing, but can be a bit
vague if you?re new to the topic.

Basically what you need to do is add registry entries to tell the various
interfaces what to do when users right click on files or directories. To save
you some reading . . .

To add a ?sync to head? command that applies to any file add the keys:

HKEY_CLASSES_ROOT\*\Shell\sync to head HKEY_CLASSES_ROOT\*\Shell\sync to head\Command

And a nameless value under the Command key that has a value something like:

P4.exe sync ?%1#head?

To add a ?sync to head? command that applies to any directory and all of its
subdirectories add the keys:

HKEY_CLASSES_ROOT\Directory\Shell\sync to head HKEY_CLASSES_ROOT\Directory\Shell\sync to head\Command

And a nameless value under the Command key that has a value something like:

P4.exe sync ?%1\ #head?

This is the basic idea behind adding canned commands. And for casual users,
canned selections are typically a good idea.

There are, however, a whole lot of issues that you?ll need to deal with in order
to make these sorts of changes truly useful. A minor problem is installing
registry.entries (try a .reg file for easy distribution). An ugly problem is
making sure the shell ?finds? p4.exe ? hint, it uses only the default
environment, so the path there needs to include p4.exe. A much bigger problem is
communicating status to the user. P4 is a command line utility and the shell
knows that. Thus it creates a temporary command interface, runs the specified
command, and closes the command interface window. However, the window gets
closed so you don?t see the results. To ?see? status returns, you need to wrap
p4 with some form of interface that captures status and presents it in a windows
dialog. Among other things, this is what Dirks?s code is doing. As an aside, I
recommend that you modify Dirk?s code to use the p4 API rather than the p4
command interface. For information about the p4 API start by looking at the
excellent presentation ?The Perforce API ? Myth and Reality? by Robert Cowham at
the 2001 Perforce User?s conference.

And of course, remember that you?re dealing with the registry. Mistakes can be
fatal, so be sure to establish appropriate backup copies before you start to
change things. The good news of course is that if you make mistakes in this area
of the registry they aren?t typically that fatal.

Regards and good luck,