Страница: 1 |
|
Вопрос: Getcommandline
|
Добавлено: 27.05.10 03:15
|
|
Автор вопроса: LEX1ERS | ICQ: 4204936
|
Добрый день. Ранее я задавал вопрос на этом форуме - "открыть с помощью "проэкт1" в итоге посоветовали скачать пример.... Тема вопроса такова...Я бы сказал даже просьба, найти исходник. Как открыть текстовый файл через explorer 2ным кликом мыши, как блокнот? Отлично было бы пример...Спасибо
Ответить
|
Номер ответа: 9 Автор ответа: Just
Вопросов: 4 Ответов: 330
|
Профиль | | #9
|
Добавлено: 28.05.10 21:44
|
lex1ers. еп ну я те же уже все объяснял месяца так 2-3 назад. я ж еще и сказал: "если че не понятно - пиши", и вот вторая тема того же содержания и все про то же... и что самое прикольное опять такая же постановка вопроса интересная...
в общих чертах набросал как должно выглядеть программное выполнение ассоциирования (делал под xp - за остальные не ручаюсь)
это в форму
-
- Option Explicit
-
- Private Sub Form_Load()
- MsgBox Command$
-
-
- Dim sProgPath As String, sKeyStr As String
- sProgPath = App.Path & "\" & App.EXEName & ".exe"
-
- sKeyStr = CetValueInfo(HKEY_CLASSES_ROOT, "txtfile\shell\open\command", "")
- If sKeyStr = "" Or sKeyStr <> sProgPath & " %1" Then
- Select Case MsgBox("Установить ассоциацию текстовых документов с этой программой?", vbYesNo + vbQuestion)
- Case vbYes
- Call CreateKeyStr(HKEY_CLASSES_ROOT, "txtfile\DefaultIcon", "", sProgPath)
- Call CreateKeyStr(HKEY_CLASSES_ROOT, "txtfile\shell\open\command", "", sProgPath & " %1")
- Case vbNo
-
-
-
-
- End Select
- End If
-
-
- Unload Me
- End Sub
это в модуль
-
- Option Explicit
-
- Public Const HKEY_CLASSES_ROOT = &H80000000
- Public Const HKEY_CURRENT_USER = &H80000001
- Public Const HKEY_LOCAL_MACHINE = &H80000002
- Public Const HKEY_USERS = &H80000003
- Public Const HKEY_PERFORMANCE_DATA = &H80000004
- Public Const HKEY_CURRENT_CONFIG = &H80000005
- Public Const HKEY_DYN_DATA = &H80000006
-
-
- Private Const REG_SZ = 1
- Private Const REG_OPTION_NON_VOLATILE = 0
- Private Const STANDARD_RIGHTS_ALL = &H1F0000
- Private Const SYNCHRONIZE = &H100000
- Private Const KEY_QUERY_VALUE = &H1
- Private Const KEY_SET_VALUE = &H2
- Private Const KEY_CREATE_SUB_KEY = &H4
- Private Const KEY_ENUMERATE_SUB_KEYS = &H8
- Private Const KEY_NOTIFY = &H10
- Private Const KEY_CREATE_LINK = &H20
- Private Const KEY_ALL_ACCESS = ((STANDARD_RIGHTS_ALL Or KEY_QUERY_VALUE Or KEY_SET_VALUE Or KEY_CREATE_SUB_KEY Or KEY_ENUMERATE_SUB_KEYS Or KEY_NOTIFY Or KEY_CREATE_LINK) And (Not SYNCHRONIZE))
-
- 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, ByVal lpSecurityAttributes As Long, phkResult As Long, lpdwDisposition As Long) As Long
- Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hkey As Long, ByVal lpSubKey As String, ByVal ulOptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
- Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hkey As Long) As Long
- Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hkey As Long, ByVal lpValueName As String) As Long
- Private Declare Function RegDeleteKey Lib "advapi32.dll" Alias "RegDeleteKeyA" (ByVal hkey As Long, ByVal lpSubKey As String) As Long
- Private Declare Function RegSetValueExStr Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal reserved As Long, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
- Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
- Private Declare Function RegQueryValueExStr Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hkey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, ByVal lpData As String, lpcbData As Long) As Long
-
-
-
-
- Public Function CetValueInfo(lKey As Long, sSubKey As String, sValueName As String) As String
- On Error Resume Next
- Dim hKeyName As Long
- Dim fData As String
- Dim fDataLen As Long
- Dim fType As Long
-
- RegOpenKeyEx lKey, sSubKey, 0&, KEY_ALL_ACCESS, hKeyName
- If hKeyName > 0 Then
- RegQueryValueEx hKeyName, sValueName, 0&, fType, ByVal 0&, fDataLen
- If fDataLen > 0 Then
- fData = String$(fDataLen - 1, vbNullChar)
- RegQueryValueExStr hKeyName, sValueName, 0&, fType, fData, fDataLen
- End If
- RegCloseKey hKeyName
- End If
- CetValueInfo = fData
- End Function
-
-
-
- Public Sub CreateKeyStr(lKey As Long, sSubKey As String, sValueName As String, sValue As String)
- On Error Resume Next
- Dim hKeyName As Long
- RegCreateKeyEx lKey, sSubKey, 0&, vbNullString, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0&, hKeyName, 0&
- If hKeyName > 0 Then
- RegSetValueExStr hKeyName, sValueName, 0&, REG_SZ, sValue, Len(sValue)
- RegCloseKey hKeyName
- End If
- End Sub
-
-
-
- Public Sub DeleteKeyValue(lKey As Long, sSubKey As String, sValueName As String)
- On Error Resume Next
- Dim hKeyName As Long
- RegOpenKeyEx lKey, sSubKey, 0&, KEY_ALL_ACCESS, hKeyName
- If hKeyName > 0 Then
- RegDeleteValue hKeyName, sValueName
- RegCloseKey hKeyName
- End If
- End Sub
-
-
-
- Public Function DeleteKey(lKey As Long, sSubKey As String)
- On Error Resume Next
- RegDeleteKey lKey, sSubKey
- End Function
Ответить
|
Страница: 1 |
Поиск по форуму