From: David on
Hope this may help others.

The solution I came up with was to create a right menu option
installer using the following:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]

@="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""

[HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]

@="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""

====================================

The UnInstaller if needed is:

Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path]



[-HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path]

==========================================

I then wrote a VB6 program (ChgPicPath.exe) which obtaines the Explorer Path
using:

Dim strExplorerPath As String

strExplorerPath = Command

========================================

Once the Path is obtained you can do what you want to with it on your
program (in my case ChgPicPath.exe)

================================

Note: When using a Registry entry to create a Right Menu Click it will ONLY
work with a compilere file ".exe".

It will NOT work from the VB IDE.







"Mayayana" <mayayana(a)invalid.nospam> wrote in message
news:i36ghj$dif$1(a)news.eternal-september.org...
> I'm guessing that Nobody and Larry already provided
> the answer you need. If you really do need to access
> the Explorer window....
> You need to get a ShellFolderView object for the
> window (via API or via the Shell Windows collection),
> which is a wrapper around the ListView that
> shows the folder content. SFV has a SelectedItems,
> which is a FolderItems collection containing the current
> selection(s) as FolderItems. FolderItem has a Path
> property.
>
>
>
> | Using XP:
> |
> | Writing a quick editing program where I want to select the
> | file in Windows Explorer, right click and bring up a menu, select my
> | program and have it open the file that was selected in Windows Explorer.
> |
> | All internet searches to get the File name and Path from Windows
> Explorer
> | have failed. Have thought about trying to extract the path from the
> | combobox which
> | appears at the top of Windows Explorer, but seems to be a long way
> around
> | the block.
> |
> | Anyone have a solution to getting the File Name and Path from Windows
> | Explorer for use in a VB program?
> |
> |
>
>


From: MikeD on
"David" <NoWhere(a)earthlink.net> wrote in message
news:OwBYPUZNLHA.5624(a)TK2MSFTNGP02.phx.gbl...
>
> The solution I came up with was to create a right menu option
> installer using the following:
>
> Windows Registry Editor Version 5.00
>
> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
>
> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>
> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
>
> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>
> It will NOT work from the VB IDE.

Sure it will, with a little effort and know-how. The know-how involves using
VB6's own command line parameters. The first step would be to substitute the
path to VB AND to your project in the above Registry entries. Be sure to use
separate quotation marks around EACH. Include the path and file name of your
project AND include the /cmd command line parameter. What this parameter
does is load whatever command line parameters are passed into the Command
Line Arguments field in Project Properties. The result is that whatever is
represented by %1 will be in Command Line Arguments. For example, your
Registry entry might look like this (I might have the actual syntax wrong
(probably easier to do this using RegEdit):

@="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change HTML
File Path\\ChgPicPath.vbp\" /cmd \"%1\""

-----
if using RegEdit, what you'd type in is this line (using the proper paths
and file names, of course):
"D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
Path\ChgPicPath.vbp" /cmd "%1"
-----

Now, do your right-click on the file and select your context menu command.
VB will launch and load your project. Open Project Properties, go to the
Make tab and look at the Command Line Arguments box. It'll have the path
and file name of the file you right-clicked. Now you can just press F5 to
run your project in the IDE, or set break points or press F8 to begin
stepping through code, etc., etc., etc.

Obviously, it'd be easier to just open the project "normally" and add the
path and file name to Command Line Arguments, but this doesn't test actually
right-clicking the file and selecting the command. But once you've verified
that part "works", there's no need to test that part further.

--
Mike

P.S. To see all of VB6's command line options (you might want to use the
/run or /runexit parameters with this), run VB6.exe with the parameter /?.
For example:

"D:\Visual Studio 6\VB98\VB6.exe" /?


From: David on
As always thanks for yours and everyone help.
Greatly appreciated.

//////////////////////////////////////////////////////////////
Haven't tried your IDE example yet.
Before that I have a couple questions related to using a "exe" rather than
from the IDE.

When I compile and right click my program I'm failing on:

Open szFileName For Input As #1

with Error 52, Bad File Name.

When I run the compiled program with a hardcoded string and
output that string and the various string parts (Path, FileName + Ext,
FileNameOnly) to label controls, NO quotes appear around the strings.

However when I use "Command" in the compiled program rather than a hard
coded string, and again output the various string parts to label controls, a
quote mark appears at the beginning or end of the various label captions.

So, I'm starting to believe that using "Command" with VB combined with
Explorer may return a different string type which is what is causing me to
error with Bad File Name.

Code follows:

Any Input appreciated.

David

///////////////////////////////////////////

'*******
'STARTUP
'*******
Label1.Caption = "junk1"
Label2.Caption = "junk2"
Label3.Caption = "junk3"
Label4.Caption = "junk4"

'*****
'MAIN
'*****
'Get File Name and Path from Explorer
' Path is on the "Command" line once the file is selected
strExplorerPath = Command

'hard coded now remmed
' strExplorerPath = "D:\VB
Modules\Explorer\Samples\RightClickMenuCopy\MenuGetPath2Copy.htm"

'Try trimming
strExplorerPath = Trim$(strExplorerPath)

'Break the Path from Explorer Apart
strFilePath = MPath.GetFilePath(strExplorerPath)
strFileNameEx = MPath.GetFileName(strExplorerPath)
strFileName = MPath.GetFileNameOnly(strExplorerPath)


Form1.Caption = strExplorerPath
Label1.Caption = strExplorerPath
Label2.Caption = strFilePath
Label3.Caption = strFileNameEx
Label4.Caption = strFileName


Exit Sub





"MikeD" <nobody(a)nowhere.edu> wrote in message
news:i3hrrt$udr$1(a)news.eternal-september.org...
> "David" <NoWhere(a)earthlink.net> wrote in message
> news:OwBYPUZNLHA.5624(a)TK2MSFTNGP02.phx.gbl...
>>
>> The solution I came up with was to create a right menu option
>> installer using the following:
>>
>> Windows Registry Editor Version 5.00
>>
>> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
>>
>> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>>
>> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
>>
>> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
>>
>> It will NOT work from the VB IDE.
>
> Sure it will, with a little effort and know-how. The know-how involves
> using VB6's own command line parameters. The first step would be to
> substitute the path to VB AND to your project in the above Registry
> entries. Be sure to use separate quotation marks around EACH. Include the
> path and file name of your project AND include the /cmd command line
> parameter. What this parameter does is load whatever command line
> parameters are passed into the Command Line Arguments field in Project
> Properties. The result is that whatever is represented by %1 will be in
> Command Line Arguments. For example, your Registry entry might look like
> this (I might have the actual syntax wrong (probably easier to do this
> using RegEdit):
>
> @="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change HTML
> File Path\\ChgPicPath.vbp\" /cmd \"%1\""
>
> -----
> if using RegEdit, what you'd type in is this line (using the proper paths
> and file names, of course):
> "D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
> Path\ChgPicPath.vbp" /cmd "%1"
> -----
>
> Now, do your right-click on the file and select your context menu command.
> VB will launch and load your project. Open Project Properties, go to the
> Make tab and look at the Command Line Arguments box. It'll have the path
> and file name of the file you right-clicked. Now you can just press F5 to
> run your project in the IDE, or set break points or press F8 to begin
> stepping through code, etc., etc., etc.
>
> Obviously, it'd be easier to just open the project "normally" and add the
> path and file name to Command Line Arguments, but this doesn't test
> actually right-clicking the file and selecting the command. But once
> you've verified that part "works", there's no need to test that part
> further.
>
> --
> Mike
>
> P.S. To see all of VB6's command line options (you might want to use the
> /run or /runexit parameters with this), run VB6.exe with the parameter /?.
> For example:
>
> "D:\Visual Studio 6\VB98\VB6.exe" /?
>
>


From: Kevin Provance on
Look up FreeFile, and whip up a FileExists routine before you open a file to
avoid such errors.

--
Customer Hatred Knows No Bounds at MSFT
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Bawwk! Paulie want a dingleball, bawwk!
"David" <NoWhere(a)earthlink.net> wrote in message
news:uncf49nNLHA.1868(a)TK2MSFTNGP05.phx.gbl...
: As always thanks for yours and everyone help.
: Greatly appreciated.
:
: //////////////////////////////////////////////////////////////
: Haven't tried your IDE example yet.
: Before that I have a couple questions related to using a "exe" rather than
: from the IDE.
:
: When I compile and right click my program I'm failing on:
:
: Open szFileName For Input As #1
:
: with Error 52, Bad File Name.
:
: When I run the compiled program with a hardcoded string and
: output that string and the various string parts (Path, FileName + Ext,
: FileNameOnly) to label controls, NO quotes appear around the strings.
:
: However when I use "Command" in the compiled program rather than a hard
: coded string, and again output the various string parts to label controls,
a
: quote mark appears at the beginning or end of the various label captions.
:
: So, I'm starting to believe that using "Command" with VB combined with
: Explorer may return a different string type which is what is causing me to
: error with Bad File Name.
:
: Code follows:
:
: Any Input appreciated.
:
: David
:
: ///////////////////////////////////////////
:
: '*******
: 'STARTUP
: '*******
: Label1.Caption = "junk1"
: Label2.Caption = "junk2"
: Label3.Caption = "junk3"
: Label4.Caption = "junk4"
:
: '*****
: 'MAIN
: '*****
: 'Get File Name and Path from Explorer
: ' Path is on the "Command" line once the file is selected
: strExplorerPath = Command
:
: 'hard coded now remmed
: ' strExplorerPath = "D:\VB
: Modules\Explorer\Samples\RightClickMenuCopy\MenuGetPath2Copy.htm"
:
: 'Try trimming
: strExplorerPath = Trim$(strExplorerPath)
:
: 'Break the Path from Explorer Apart
: strFilePath = MPath.GetFilePath(strExplorerPath)
: strFileNameEx = MPath.GetFileName(strExplorerPath)
: strFileName = MPath.GetFileNameOnly(strExplorerPath)
:
:
: Form1.Caption = strExplorerPath
: Label1.Caption = strExplorerPath
: Label2.Caption = strFilePath
: Label3.Caption = strFileNameEx
: Label4.Caption = strFileName
:
:
: Exit Sub
:
:
:
:
:
: "MikeD" <nobody(a)nowhere.edu> wrote in message
: news:i3hrrt$udr$1(a)news.eternal-september.org...
: > "David" <NoWhere(a)earthlink.net> wrote in message
: > news:OwBYPUZNLHA.5624(a)TK2MSFTNGP02.phx.gbl...
: >>
: >> The solution I came up with was to create a right menu option
: >> installer using the following:
: >>
: >> Windows Registry Editor Version 5.00
: >>
: >> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
: >>
: >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
: >>
: >> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
: >>
: >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\" \"%1\""
: >>
: >> It will NOT work from the VB IDE.
: >
: > Sure it will, with a little effort and know-how. The know-how involves
: > using VB6's own command line parameters. The first step would be to
: > substitute the path to VB AND to your project in the above Registry
: > entries. Be sure to use separate quotation marks around EACH. Include
the
: > path and file name of your project AND include the /cmd command line
: > parameter. What this parameter does is load whatever command line
: > parameters are passed into the Command Line Arguments field in Project
: > Properties. The result is that whatever is represented by %1 will be in
: > Command Line Arguments. For example, your Registry entry might look
like
: > this (I might have the actual syntax wrong (probably easier to do this
: > using RegEdit):
: >
: > @="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change HTML
: > File Path\\ChgPicPath.vbp\" /cmd \"%1\""
: >
: > -----
: > if using RegEdit, what you'd type in is this line (using the proper
paths
: > and file names, of course):
: > "D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
: > Path\ChgPicPath.vbp" /cmd "%1"
: > -----
: >
: > Now, do your right-click on the file and select your context menu
command.
: > VB will launch and load your project. Open Project Properties, go to
the
: > Make tab and look at the Command Line Arguments box. It'll have the
path
: > and file name of the file you right-clicked. Now you can just press F5
to
: > run your project in the IDE, or set break points or press F8 to begin
: > stepping through code, etc., etc., etc.
: >
: > Obviously, it'd be easier to just open the project "normally" and add
the
: > path and file name to Command Line Arguments, but this doesn't test
: > actually right-clicking the file and selecting the command. But once
: > you've verified that part "works", there's no need to test that part
: > further.
: >
: > --
: > Mike
: >
: > P.S. To see all of VB6's command line options (you might want to use
the
: > /run or /runexit parameters with this), run VB6.exe with the parameter
/?.
: > For example:
: >
: > "D:\Visual Studio 6\VB98\VB6.exe" /?
: >
: >
:
:

From: David on
Mr. Provance:

That's "Not" where the problem is coming from.
After a lot work, it appears Command is returning a string with
quotes delimited around it while a normal VB string is shown without.
Displayed both to labels and that is the difference showing.

However, after removing both quotes (beginning and ending)
rather than Err 52 (Bad File Name). The program locks big time.

So OBVIOUSLY I'm doing something wrong by getting the file name
in VB using Command from Explorer and then trying to search
and replace within that file name from VB using a Right Context Menu.

Any ideas??.



"Kevin Provance" <k(a)p.c> wrote in message
news:i3kv1p$82e$1(a)news.eternal-september.org...
> Look up FreeFile, and whip up a FileExists routine before you open a file
> to
> avoid such errors.
>
> --
> Customer Hatred Knows No Bounds at MSFT
> Free usenet access at http://www.eternal-september.org
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
>
> Bawwk! Paulie want a dingleball, bawwk!
> "David" <NoWhere(a)earthlink.net> wrote in message
> news:uncf49nNLHA.1868(a)TK2MSFTNGP05.phx.gbl...
> : As always thanks for yours and everyone help.
> : Greatly appreciated.
> :
> : //////////////////////////////////////////////////////////////
> : Haven't tried your IDE example yet.
> : Before that I have a couple questions related to using a "exe" rather
> than
> : from the IDE.
> :
> : When I compile and right click my program I'm failing on:
> :
> : Open szFileName For Input As #1
> :
> : with Error 52, Bad File Name.
> :
> : When I run the compiled program with a hardcoded string and
> : output that string and the various string parts (Path, FileName + Ext,
> : FileNameOnly) to label controls, NO quotes appear around the strings.
> :
> : However when I use "Command" in the compiled program rather than a
> hard
> : coded string, and again output the various string parts to label
> controls,
> a
> : quote mark appears at the beginning or end of the various label
> captions.
> :
> : So, I'm starting to believe that using "Command" with VB combined with
> : Explorer may return a different string type which is what is causing me
> to
> : error with Bad File Name.
> :
> : Code follows:
> :
> : Any Input appreciated.
> :
> : David
> :
> : ///////////////////////////////////////////
> :
> : '*******
> : 'STARTUP
> : '*******
> : Label1.Caption = "junk1"
> : Label2.Caption = "junk2"
> : Label3.Caption = "junk3"
> : Label4.Caption = "junk4"
> :
> : '*****
> : 'MAIN
> : '*****
> : 'Get File Name and Path from Explorer
> : ' Path is on the "Command" line once the file is selected
> : strExplorerPath = Command
> :
> : 'hard coded now remmed
> : ' strExplorerPath = "D:\VB
> : Modules\Explorer\Samples\RightClickMenuCopy\MenuGetPath2Copy.htm"
> :
> : 'Try trimming
> : strExplorerPath = Trim$(strExplorerPath)
> :
> : 'Break the Path from Explorer Apart
> : strFilePath = MPath.GetFilePath(strExplorerPath)
> : strFileNameEx = MPath.GetFileName(strExplorerPath)
> : strFileName = MPath.GetFileNameOnly(strExplorerPath)
> :
> :
> : Form1.Caption = strExplorerPath
> : Label1.Caption = strExplorerPath
> : Label2.Caption = strFilePath
> : Label3.Caption = strFileNameEx
> : Label4.Caption = strFileName
> :
> :
> : Exit Sub
> :
> :
> :
> :
> :
> : "MikeD" <nobody(a)nowhere.edu> wrote in message
> : news:i3hrrt$udr$1(a)news.eternal-september.org...
> : > "David" <NoWhere(a)earthlink.net> wrote in message
> : > news:OwBYPUZNLHA.5624(a)TK2MSFTNGP02.phx.gbl...
> : >>
> : >> The solution I came up with was to create a right menu option
> : >> installer using the following:
> : >>
> : >> Windows Registry Editor Version 5.00
> : >>
> : >> [HKEY_CLASSES_ROOT\*\Shell\Change HTML File Path\Command]
> : >>
> : >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\"
> \"%1\""
> : >>
> : >> [HKEY_CLASSES_ROOT\Directory\Shell\Change HTML File Path\Command]
> : >>
> : >> @="\"C:\\Program Files\\Change HTML File Path\\ChgPicPath.exe\"
> \"%1\""
> : >>
> : >> It will NOT work from the VB IDE.
> : >
> : > Sure it will, with a little effort and know-how. The know-how involves
> : > using VB6's own command line parameters. The first step would be to
> : > substitute the path to VB AND to your project in the above Registry
> : > entries. Be sure to use separate quotation marks around EACH. Include
> the
> : > path and file name of your project AND include the /cmd command line
> : > parameter. What this parameter does is load whatever command line
> : > parameters are passed into the Command Line Arguments field in Project
> : > Properties. The result is that whatever is represented by %1 will be
> in
> : > Command Line Arguments. For example, your Registry entry might look
> like
> : > this (I might have the actual syntax wrong (probably easier to do this
> : > using RegEdit):
> : >
> : > @="\"D:\\Visual Studio 6\\VB98\\VB6.exe\" \"D:\\My Projects\\Change
> HTML
> : > File Path\\ChgPicPath.vbp\" /cmd \"%1\""
> : >
> : > -----
> : > if using RegEdit, what you'd type in is this line (using the proper
> paths
> : > and file names, of course):
> : > "D:\Visual Studio 6\VB98\VB6.exe" "D:\My Projects\Change HTML File
> : > Path\ChgPicPath.vbp" /cmd "%1"
> : > -----
> : >
> : > Now, do your right-click on the file and select your context menu
> command.
> : > VB will launch and load your project. Open Project Properties, go to
> the
> : > Make tab and look at the Command Line Arguments box. It'll have the
> path
> : > and file name of the file you right-clicked. Now you can just press
> F5
> to
> : > run your project in the IDE, or set break points or press F8 to begin
> : > stepping through code, etc., etc., etc.
> : >
> : > Obviously, it'd be easier to just open the project "normally" and add
> the
> : > path and file name to Command Line Arguments, but this doesn't test
> : > actually right-clicking the file and selecting the command. But once
> : > you've verified that part "works", there's no need to test that part
> : > further.
> : >
> : > --
> : > Mike
> : >
> : > P.S. To see all of VB6's command line options (you might want to use
> the
> : > /run or /runexit parameters with this), run VB6.exe with the parameter
> /?.
> : > For example:
> : >
> : > "D:\Visual Studio 6\VB98\VB6.exe" /?
> : >
> : >
> :
> :
>