Seite 1 von 1

Eigenes URL-Protokoll registrieren

Verfasst: 15.11.2009 10:15
von X360 Andy

Code: Alles auswählen

;##########################
;Eigenes URL-Protokoll registrieren
;##########################

EnableExplicit

Define StringBuffer$, ProgramName$, ProgramPath$, ProtokollName$
Define NewKey, KeyInfo
; -- Dieser Code braucht Administrator Rechte!

; -- Name des URL-Protokolls
ProtokollName$ = "test"

; -- Absoulten Pfad der Datei (geg. Parameter anhängen)
ProgramPath$ = "C:\Windows\System32\notepad.exe"

Procedure Set_Reg_URL_Protokoll_Value(ProtokollName$, ProgramPath$ )
  Protected NewKey, KeyInfo
  Protected StringBuffer$
  If RegCreateKeyEx_(#HKEY_CLASSES_ROOT, ProtokollName$, 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo) = #ERROR_SUCCESS
    ; -- Warscheinlich nicht schoen geloest, schreibt in den Root vom neuen Protokoll Wichtige Daten hinein
    RegSetValueEx_(NewKey, "URL Protocol", 0, #REG_SZ, "", 1)
    RegCloseKey_(NewKey)
    RegCreateKeyEx_(#HKEY_CLASSES_ROOT, ProtokollName$+"\shell\open\command", 0, 0, #REG_OPTION_NON_VOLATILE, #KEY_ALL_ACCESS, 0, @NewKey, @KeyInfo)

    ; -- "%1" Sendet den Pfad der Datei an das Programm als Parameter
     StringBuffer$ = Chr(34) + ProgramPath$ + Chr(34)+" "+Chr(34)  + "%1" +Chr(34) 
    RegSetValueEx_(NewKey, "", 0, #REG_SZ, StringBuffer$, Len(StringBuffer$) + 1)
    RegCloseKey_(NewKey)
    ProcedureReturn 1
  Else
    ProcedureReturn 0
  EndIf
EndProcedure

Debug Set_Reg_URL_Protokoll_Value(ProtokollName$, ProgramPath$)
Aufgrund diesem Threads habe ich eben dieses Beispiel gebastelt.

Viel spass damit
Feedback erwünscht

Re: Eigenes URL-Protokoll registrieren

Verfasst: 15.11.2009 10:47
von Tsuki-Namida
:allright: echt super :) es funktioniert einfach super :)

Re: Eigenes URL-Protokoll registrieren

Verfasst: 17.11.2009 17:31
von jojo1541
interessant.. :allright: