Programmspezivische Dateiendung in der Registry eintragen (an den Anfang deines Codes packen)
. Funktioniert hier bei meinem MusikPlayer PB Version 5.30 x86:
Code: Alles auswählen
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;- Registriere DeinProgramm und Icon in der Registry
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#SHCNE_ASSOCCHANGED = $8000000 ; überprüfe Eintrag beim Start des Programmes
#SHCNF_IDLIST = $0 ; überprüfe Eintrag beim Start des Programmes
Procedure CreateRegistryKeyValue(topKey.i, KeyName$, ValueName$, Value$, Type.i=#REG_SZ, ComputerName$="")
Protected SecurityAttributes.SECURITY_ATTRIBUTES
Protected NewKey.i, GetHandle.i, RemoteRegistry.i
Protected Datas$, Value.i
Protected cbData.i
; Key erstellen
If Left(KeyName$, 1) = "\"
KeyName$ = Right(KeyName$, Len(KeyName$) - 1)
EndIf
Debug p
If ComputerName$ = ""
GetHandle = RegCreateKeyEx_(topKey, KeyName$, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @SecurityAttributes, @NewKey, @GetHandle)
Else
RegConnectRegistry_(ComputerName$, topKey, @RemoteRegistry)
GetHandle = RegCreateKeyEx_(RemoteRegistry, KeyName$, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, @SecurityAttributes, @NewKey, @GetHandle)
EndIf
; Key setzen
If GetHandle = #ERROR_SUCCESS
cbData = 255
Datas$ = Space(255)
Select Type
Case #REG_SZ
GetHandle = RegSetValueEx_(NewKey, ValueName$, 0, #REG_SZ, @Value$, StringByteLength(Value$) + 1)
Case #REG_DWORD
Value = Val(Value$)
GetHandle = RegSetValueEx_(NewKey, ValueName$, 0, #REG_DWORD, @Value$, 4)
EndSelect
RegCloseKey_(NewKey)
EndIf
EndProcedure
Procedure AssociateFileExtension(Key$, Ext$, ExtDescription$, Programm$, Icon$, PrgKey$, CmdDescription$, CmdKey$) ; Dateierweiterung in Registry eintragen
Protected Cmd$ ; Command
Protected CmdPath$ ; Pfad zu dem Eintrag
CmdPath$ = Key$+"\shell\"+CmdDescription$+"\command" ; Pfad erstellen
Cmd$ = Chr('"')+Programm$+Chr('"') + " " + Chr('"')+"%1"+Chr('"') ; Command erstellen
CreateRegistryKeyValue(#HKEY_CLASSES_ROOT, "."+Ext$, "", Key$) ; Schlüssel für die Erweiterung
CreateRegistryKeyValue(#HKEY_CLASSES_ROOT, Key$, "", ExtDescription$) ; Beschreibung
CreateRegistryKeyValue(#HKEY_CLASSES_ROOT, CmdPath$, "", Cmd$) ; Programmaufruf
If Icon$ ; Wenn ein Icon angegeben ist ...
CreateRegistryKeyValue(#HKEY_CLASSES_ROOT, Key$+"\DefaultIcon", "", Icon$) ; Icon-Datei eintragen
EndIf
EndProcedure
AssociateFileExtension("DeinProgramm", "zlv", "DeinProgramm", ProgramFilename(), ProgramFilename() + ",-1", "DeinProgramm", "open", "") ; REGISTRY EINTRAG für OPEN DeinProgramm
SHChangeNotify_(#SHCNE_ASSOCCHANGED, #SHCNF_IDLIST, 0, 0) ; überprüfe Eintrag beim Start des Programmes
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; Ende Registriere DeinProgramm und Icon in der Registry
;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////