|
-
Aug 29th, 2000, 07:43 AM
#1
Thread Starter
Fanatic Member
I've got a little app that makes folders (save right-click-new-folder-ing till your fingers come off) and I'd like to be able to call it from that very same right-click menu, so when I'm in Windaes Destroyer I can make folders to my heart's content. Now, I've mucked about a bit with registry entries et al, but I'd really like to learn more about this, and one of you guys once told me about a place in the MSDN site that goes into detail - anyone got any idea where that might be?
-
Aug 29th, 2000, 08:00 AM
#2
In Windows Explorer choose View|Folder Options|File Types and select Folder in the ListView. Click on the Edit command button and then click New. In the dialog that popsup type the text that you want to see in the menu in the first textbox and the name and path to your application in the second. Click OK and close all dialogs.
Now right click on any folder in Explorer and there you go...
-
Aug 29th, 2000, 08:05 AM
#3
Thread Starter
Fanatic Member
Superb. It's amazing how purblind I can be...
Joacim, how would I do this from code - I mean, could I get my little app to check this is set up every time it runs?
-
Aug 29th, 2000, 08:15 AM
#4
Add code to write to the registry. The key should be:
HKEY_CLASSES_ROOT\Folder\Shell\TheTextToAppearInTheMenu\Command
And write the name and path of your application to the default value.
-
Aug 29th, 2000, 09:31 AM
#5
Thread Starter
Fanatic Member
Joacim, thanks. Would you be able to post some example code for that?
I also wrote a little file splitter app, and I would have loved to get it to show a split file option for all files except those with certain extensions - ie, one's that were splits. I think I need to write a dll to do this - can you help me with this?
-
Aug 29th, 2000, 12:06 PM
#6
transcendental analytic
By using my registry module (you can download it at my homepage) you could just assign the default value:
Code:
Regval("HKEY_CLASSES_ROOT\Folder\Shell\TheTextToAppearInTheMenu\Command\Open\")=app.path & app.exename & " %1"
remember the last "\"
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 29th, 2000, 12:08 PM
#7
Code:
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const REG_SZ = 1&
Private Const ERROR_SUCCESS = 0&
Private Const KEY_SET_VALUE = &H2
Private Const REG_CREATED_NEW_KEY = &H1
Private Declare Function RegCloseKey _
Lib "advapi32.dll" ( _
ByVal hKey As Long) As Long
Private Declare Function RegSetValueEx _
Lib "advapi32.dll" Alias "RegSetValueExA" ( _
ByVal hKey As Long, _
ByVal lpValueName As String, _
ByVal Reserved As Long, _
ByVal dwType As Long, _
lpData As Any, _
ByVal cbData As Long) As Long
Private Declare Function RegCreateKeyEx _
Lib "advapi32.dll" Alias "RegCreateKeyExA" ( _
ByVal hKey As Long, _
ByVal lpSubKey As String, _
ByVal Reserved As Long, _
ByVal lpClass As String, _
ByVal dwOptions As Long, _
ByVal samDesired As Long, _
lpSecurityAttributes As Long, _
phkResult As Long, _
lpdwDisposition As Long) As Long
Public Sub CheckIfAdded()
Const MENUCAPTION As String = "StringInTheMenu"
Const THEAPPPATH As String = "C:\ThePathToYourApp\TheNameOfYourApp.exe"
Dim hCurKey As Long
Dim lngResult As Long
Dim lngDisposition As Long
lngResult = RegCreateKeyEx( _
HKEY_CLASSES_ROOT, _
"Folder\Shell\" & MENUCAPTION & "\Command", _
0&, vbNullString, _
0&, KEY_SET_VALUE, _
vbNull, hCurKey, _
lngDisposition)
If lngResult = ERROR_SUCCESS Then
If lngDisposition = REG_CREATED_NEW_KEY Then
RegSetValueEx hCurKey, "", 0&, REG_SZ, ByVal THEAPPPATH, Len(THEAPPPATH)
End If
Else
'Houston we have a problem....
MsgBox "Error in creating registry key!", vbCritical
Exit Sub
End If
RegCloseKey hCurKey
End Sub
-
Aug 29th, 2000, 06:05 PM
#8
Addicted Member
It Work!
I must take off my cap for you and some of the other Gurus too.
Where did you get that code?
-
Aug 29th, 2000, 06:15 PM
#9
Addicted Member
OK, I tried doing this HKEY_CLASSES_ROOT\Folder\Shell\TheTextToAppearInTheMenu\Command
I only see it when I right click on a folder. How do you do it to file level?
Thanks
[Edited by Shark on 08-29-2000 at 08:32 PM]
-
Aug 30th, 2000, 04:08 AM
#10
transcendental analytic
Code:
regval("ROOT\*\shell\open\command\")="""" & app.path & "\" & app.exename & " %1"""
This should work for all files, but if you change the "*" to whatever extension you want it will work only with that extension
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Aug 30th, 2000, 04:33 AM
#11
Originally posted by kedaman
Code:
regval("ROOT\*\shell\open\command\")="""" & app.path & "\" & app.exename & " %1"""
This should work for all files, but if you change the "*" to whatever extension you want it will work only with that extension
This is true but I wouldn't recommend using \shell\open\command\ because that might overwrite the default Open command for the file.
Change the word open in the path to whatever caption you want to have in the popup menu.
-
Aug 30th, 2000, 04:43 AM
#12
Addicted Member
-
Aug 30th, 2000, 04:53 AM
#13
Thread Starter
Fanatic Member
Hey Shark, who's post was this anyway? An apt username if ever etc. etc.
Now, I'D like to say thanks chaps, marvellous stuff, I've added your code to my app Joacim, and it works great.
But do any of you know about the dll thing? I think Winzip references a dll in the registry, I would imagine to give different responses to files with different extensions. Any ideas?
-
Aug 30th, 2000, 06:11 AM
#14
transcendental analytic
There's a typelib somwhere that you can do mny things with the context menus and dragged files, i have it but not on this comp, you could ask Aaron for it since i got it from him.
But if you just need to respond to different extension you would only have to point the .ext\shell\***\command default value to different exes, or why not put extra parameters to it
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|