Szybkie szukanie
Słowo kluczowe:
sobota, 11 luty 2012
Start arrow Tips & Tricks arrow Tworzenie skojarzenia pliku z aplikacją.
Tworzenie skojarzenia pliku z aplikacją. Drukuj E-mail
Napisał Administrator   
sobota, 21 styczeń 2006
'utworz nowy projekt z command button
'wstaw kod w odpowiednie miejsca
'dokonaj odpowiednich zmian w kodzie, patrz znak *

Declare Function RegCreateKey& Lib "advapi32.DLL" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&)
Declare Function RegSetValue& Lib "advapi32.DLL" Alias "RegSetValueA" (ByVal hKey&, ByVal lpszSubKey$, ByVal fdwType&, ByVal lpszValue$, ByVal dwLength&)

' Kody zwrotne Registration functions.
Public Const ERROR_SUCCESS = 0&
Public Const ERROR_BADDB = 1&
Public Const ERROR_BADKEY = 2&
Public Const ERROR_CANTOPEN = 3&
Public Const ERROR_CANTREAD = 4&

Public Const ERROR_CANTWRITE = 5&
Public Const ERROR_OUTOFMEMORY = 6&
Public Const ERROR_INVALID_PARAMETER = 7&
Public Const ERROR_ACCESS_DENIED = 8&

Global Const HKEY_CLASSES_ROOT = &H80000000
Public Const MAX_PATH = 256&
Public Const REG_SZ = 1


Private Sub Command1_Click()
Dim sKeyName As String 'Zawiera nazwe klucza w rejestrze.
Dim sKeyValue As String 'Zawiera wartosc klucza w rejestrze
Dim ret& 'Zawiera ewentualne bledy zwrocone przez API

Dim lphKey& 'Holds created key handle from RegCreateKey.

'Tworzy wpis w rejestrze - "MyApp".
sKeyName = "MyApp" '*
sKeyValue = "My Application" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)

'Tworzy wpis w rejestrze .BAR skojarzony z "MyApp".
sKeyName = ".bar" '*
sKeyValue = "MyApp" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)

ret& = RegSetValue&(lphKey&, "", REG_SZ, sKeyValue, 0&)

'This sets the command line for "MyApp".
sKeyName = "MyApp" '*
sKeyValue = "notepad.exe %1" '*
ret& = RegCreateKey&(HKEY_CLASSES_ROOT, sKeyName, lphKey&)
ret& = RegSetValue&(lphKey&, "shell\open\command", REG_SZ, sKeyValue, MAX_PATH)

End Sub

Komentarze

Aby dodać komentarz zaloguj się. Jeśli nie masz konta, załóż je sobie.
Tylko zarejestrowani użytkownicy mogą pisać komentarze.

Powered by AkoComment 2.0!

< Poprzedni   Następny >

Menu główne
Start
Teoria
VB.NET
Api
Tips & Tricks
Warsztat
VBMagazine
Pliki
Forum
Literatura
Ankiety
Linki
Szukaj
Wyślij program
Napisz do nas
Redakcja
Logowanie
Login

Hasło

Zapamiętaj mnie
Nie pamiętasz hasła?
Nie masz konta? Załóż je sobie
Gościmy
Aktualnie jest 49 gości online
Statystyka
Użytkownicy: 11345
Newsy: 237
Odnośniki: 48
Odwiedzających: 4327609
Mambo is Free Software released under the GNU/GPL License.