-
Ok guys,
1) Anyone know of the location i add things in the registry to have my icon and my text appear as an option, then run my program with parms when a certain type of file is right clicked in explorer and also set it so when a file type is double clicked it calls my program with certain parms?
2) I want to read from a file, one byte at a time to avoid HUGE variables when reading large files.. i need to open it using the binary access method, so i can read any EOF markers that are located in the file and as such i cannot use simple Do Until EOF()
3) The MSCOMM control doesnt seem to support standard port speeds?
Thanks
-
Think this is from vb-world
1.
Code:
'Declarations
Public Type mnuCommands
Captions As New Collection
Commands As New Collection
End Type
Public Type filetype
Commands As mnuCommands
Extension As String
ProperName As String
FullName As String
ContentType As String
IconPath As String
IconIndex As Integer
End Type
Public Const REG_SZ = 1
Public Const HKEY_CLASSES_ROOT = &H80000000
Public Declare Function RegCloseKey Lib _
"advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegCreateKey Lib _
"advapi32" Alias "RegCreateKeyA" (ByVal _
hKey As Long, ByVal lpszSubKey As String, _
phkResult As Long) As Long
Public Declare Function RegSetValueEx Lib _
"advapi32" Alias "RegSetValueExA" (ByVal _
hKey As Long, ByVal lpszValueName As String, _
ByVal dwReserved As Long, ByVal fdwType As _
Long, lpbData As Any, ByVal cbData As Long) As Long
'Add the following code to a module:
Public Sub CreateExtension(newfiletype As filetype)
Dim IconString As String
Dim Result As Long, Result2 As Long, ResultX As Long
Dim ReturnValue As Long, HKeyX As Long
Dim cmdloop As Integer
IconString = newfiletype.IconPath & "," & _
newfiletype.IconIndex
If Left$(newfiletype.Extension, 1) <> "." Then _
newfiletype.Extension = "." & newfiletype.Extension
RegCreateKey HKEY_CLASSES_ROOT, _
newfiletype.Extension,Result
ReturnValue = RegSetValueEx(Result, "", 0, REG_SZ, _
ByVal newfiletype.ProperName, _
LenB(StrConv(newfiletype.ProperName, vbFromUnicode)))
'Set up content type
If newfiletype.ContentType <> "" Then
ReturnValue = RegSetValueEx(Result, _
"Content Type", 0, REG_SZ, ByVal _
CStr(newfiletype.ContentType), _
LenB(StrConv(newfiletype.ContentType, vbFromUnicode)))
End If
RegCreateKey HKEY_CLASSES_ROOT, _
newfiletype.ProperName, Result
If Not IconString = ",0" Then
RegCreateKey Result, "DefaultIcon", _
Result2 'Create The Key of "ProperNameDefaultIcon"
ReturnValue = RegSetValueEx(Result2, _
"", 0, REG_SZ, ByVal IconString, _
LenB(StrConv(IconString, vbFromUnicode)))
'Set The Default Value for the Key
End If
ReturnValue = RegSetValueEx(Result, _
"", 0, REG_SZ, ByVal newfiletype.FullName, _
LenB(StrConv(newfiletype.FullName, vbFromUnicode)))
RegCreateKey Result, ByVal "Shell", ResultX
'Create neccessary subkeys for each command
For cmdloop = 1 To newfiletype.Commands.Captions.Count
RegCreateKey ResultX, ByVal _
newfiletype.Commands.Captions(cmdloop), Result
RegCreateKey Result, ByVal "Command", Result2
Dim CurrentCommand$
CurrentCommand = newfiletype.Commands.Commands(cmdloop)
ReturnValue = RegSetValueEx(Result2, _
"", 0, REG_SZ, ByVal CurrentCommand$, _
LenB(StrConv(CurrentCommand$, vbFromUnicode)))
RegCloseKey Result
RegCloseKey Result2
Next
RegCloseKey Result2
End Sub
'Then use this code to create the association:
Dim myfiletype As filetype
myfiletype.ProperName = "MyFile"
myfiletype.FullName = "My File Type"
myfiletype.ContentType = "SomeMIMEtype"
myfiletype.Extension = ".MYF"
myfiletype.Commands.Captions.Add "Open"
myfiletype.Commands.Commands.Add _
"c:\windows\notepad.exe ""%1"""
myfiletype.Commands.Captions.Add "Print"
myfiletype.Commands.Commands.Add _
"c:\windows\n
otepad.exe ""%1"" /P"
CreateExtension myfiletype
2. Read until Loc(FileNumber) = FileLen(FileName)
Haven't tried this before but it might work.
3. The default for mscomm is 9600. Change the settings of the control to change the speed of the port
-
Ok, i have created the default item for MY file extension, now i want to add to the context menu shown for ALL other file extensions EXCEPT mine, also does anyone know how to put an icon beside the text in the context menu?
-
hmm.... when you add a key to HKEY_CLASSES_ROOT\*\Shellex\ContextMenuHandler\
you can get it to display at all extensions, but I don't know if you can exclude them...
I think it's possible to add it to every extension except your's but that'll be rediculous because you don't know when a new extension gets added :(
-
Hi, what format do i put things in under this key?
Thanks