А как это делается?
-
-
- Private Declare Function RegCreateKey Lib "advapi32.dll" _
- Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey _
- As String, phkResult 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 RegCloseKey Lib "advapi32.dll" _
- (ByVal hKey As Long) As Long
- Private Const HKEY_CLASSES_ROOT = &H80000000
- Private Sub AssociateMyApp(ByVal sAppName As String, _
- ByVal sEXE As String, ByVal sExt As String, Optional ByVal sIcon As String)
- Dim lRegKey As Long
- Call RegCreateKey(HKEY_CLASSES_ROOT, sExt, lRegKey)
- Call RegSetValueEx(lRegKey, "", 0&, 1, ByVal sAppName, Len(sAppName))
- Call RegCloseKey(lRegKey)
- Call RegCreateKey(HKEY_CLASSES_ROOT, sAppName & "\Shell\Open\Command", lRegKey)
- Call RegSetValueEx(lRegKey, "", 0&, 1, ByVal sEXE, Len(sEXE))
- Call RegCloseKey(lRegKey)
- If Len(sIcon) Then
- Call RegCreateKey(HKEY_CLASSES_ROOT, sAppName & "\DefaultIcon", lRegKey)
- Call RegSetValueEx(lRegKey, "", 0&, 1, ByVal sIcon, Len(sIcon))
- Call RegCloseKey(lRegKey)
- End If
- End Sub
-
-
-
- AssociateMyApp("My TextEditor", "C:\MyProgram.exe %1", ".txt", "C:\icon.ico")
-
-
-
- Dim sCommand As String
- Dim sFileName As String
- sCommand = Command$()
- If Left$ (sCommand, 1) = Chr (34) Then
- sCommand = Right$ (sCommand, Len (sCommand) - 1)
- End If
- If Right$ (sCommand, 1) = Chr (34) Then
- sCommand = Left$ (sCommand, Len (sCommand) - 1)
- End If
- sFileName = sCommand
-
Ответить
|