Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Retrieve multiple filenames from Windows Explorer context menu

135 views
Skip to first unread message

Robert

unread,
Jan 17, 2004, 2:20:39 PM1/17/04
to
Hi,

For my new application i need to retrieve multiple filenames from the
Windows Explorer context menu (any kind of file, no matter what extension) .
I created the registry keys ( Myapp.exe %L ) and retrieving one filename
isn't a problem.
But retrieving al the filenames in one instance of my application is a BIG
problem.
I did a search and found related things like, App.PrevInstance,
Mutex.....but i still don't understand how to fix this.

Has somebody a small example, only to solve this problem ? (retrieving
multiple filenames from the Windows Explorer context menu )

Thx

Robert


Tom Esh

unread,
Jan 17, 2004, 7:57:26 PM1/17/04
to
On Sat, 17 Jan 2004 20:20:39 +0100, "Robert" <nom...@nomail.com>
wrote:


Here's two ways of dealing with it:
One is DDE (Dynamic Data Exchange), which is the Windows shell's
built-in method of dealing with it. At runtime, the individual
filenames will be passed to your app as the CmdStr argument in the
LinkExecute event. The basic steps to set it up are:
(App Setup):
1) Set the LinkMode property of your app's main form to Source.
2) Set the LinkTopic property of the same form to a string that
describes the action - "FileOpen" for example. (Doesn't really matter
what the string is, as long as you use the same one later in step #8.)
3) Build the exe.
(Registry Setup - via the Explorer, View, Options, FileTypes dialog):
4) Find the type name of the associated file and doubleclick it to
open the dialog.
5) Doubleclick the "open" item in the Action list to bring up the
Action dialog.
6) Check the "Use DDE" checkbox.
7) Enter "%1" (include the quotes) in the DDE Message field.
8) Enter the topic name from step 2 in the "Topic" field.

The registry setup can also be done programatically via the Api, or by
including a .reg file to be run on install/setup. Note however that
it's probably not a good idea to do it from within the program itself
if it will be installed on networked systems. (Typically registry
modifications require that the user have admin privledges.)

Another method is to detect a previous instance of the app when
starting, and if found, pass the new command line (i.e. filename) to
the previous instance with the Api (WM_COPYDATA message) and then
terminate. This requires subclassing the main form to detect the
message. I believe there's an example of this method at:
http://www.mvps.org/vb/index2.html


-Tom
MVP - Visual Basic
(please post replies to the newsgroup)

Robert

unread,
Jan 19, 2004, 12:59:29 PM1/19/04
to
Tom,

Am i right that in the first way there must be an associated file ?

I'd like to retrieve the filename of every selected file, no matter what
kind of file, even selecting different files)

At the second way, i found the PrevInst.zip example and try to figure out
how to use it for my new app.

It seems a little complicated.

Thx,

Robert


"Tom Esh" <tjeshGi...@earthlink.net> wrote in message
news:1bmj001osiatmlp09...@4ax.com...

Tom Esh

unread,
Jan 19, 2004, 5:25:36 PM1/19/04
to
On Mon, 19 Jan 2004 18:59:29 +0100, "Robert" <nom...@nomail.com>
wrote:

>Am i right that in the first way there must be an associated file ?
>
>I'd like to retrieve the filename of every selected file, no matter what
>kind of file, even selecting different files)

Yep. The DDE method works via association, so that's not applicable in
this case.

>At the second way, i found the PrevInst.zip example and try to figure out
>how to use it for my new app.
>
>It seems a little complicated.

Don't let a little subclassing throw you <g>

However you can do something similar without subclassing by using a
non-visible TextBox on your app's main form. In your startup Sub Main
proceedure, look for a previous instance. If found, use it's hwnd with
FindWindowEx to obtain the hwnd of the textbox. Send the textbox the
command line with the WM_SETTEXT message. This will cause the
textbox's Change event to fire in the previous instance, and it can do
whatever with the contents.

Robert

unread,
Jan 20, 2004, 1:47:58 AM1/20/04
to
Tom,

Thanks for the answers. I'll try them this weekend (i' am very busy this
moment :-)) )

It's very interesting stuff. I think that subclassing is the biggest
challenge for me.

I try to find more information about that. Unfortunately the PrevInst
example is not well commented.

I' am grateful that the MVP's (and all the others of course) take so much
time to answer the questions.

Thx,

Robert

GrandpaTCAM

unread,
Jan 21, 2004, 9:05:38 AM1/21/04
to
Try pressing [SHIFT] or [CTRL] keys to select multiple files into one
string. You have to disassemble the string into seperate file names.
Greetings,
Dolphe

"Robert" <nom...@nomail.com> schreef in bericht
news:iWfOb.208161$_x2.421935@zonnet-reader-1...

Robert

unread,
Jan 21, 2004, 2:06:44 PM1/21/04
to
Dolphe,

This doesn't work using the Windows explorer context menu, only directly
from the commandline. (I' am using the "Split" function)

Robert


Robert

unread,
Jan 26, 2004, 2:16:09 PM1/26/04
to
Have you ever tried this, disassambeling the string is not the problem (it
works fine from the commandline) but thats not the way windows explorer
sends the filenames. It's not a string with al the filenames within it !

Robert

"GrandpaTCAM" <anony...@cat.com> wrote in message
news:400e8734$0$518$cd19...@news.wanadoo.nl...

0 new messages