I know its been awhile since Mr.entropyreduction replied, but I just 
found the time to look at the code and test it.
The tests worked fine and gave me the basic understanding I needed!  
Thank you so much! - BGM
Here is what I made of it (I abandoned the idea of trying to save the 
previous value, which was probably "" anyways!).

;Add OpenWithNotepad to the Context Menu for all files

;how of 0 just displays the key
;how of 1 adds "Open With Notepad"
;how of 2 deletes the key
;how of 3 adds/changes the key to open with Notepad2

function Notepad(how)
    local starshell =     ?"HKCR\*\shell\"
    local openWnp =     "Open With Notepad"
    local openWnpCmd =    "command"
    local sPath =        starshell++openWnp++"\\"++openWnpCmd++"\\"

    ;local sPath = ?"HKCR\*\shell\Open with Notepad\command\"  ;;notice 
final slash: \, meaning get default value
    local currentvalue = reg.get_value(sPath)

    local notepadkey=?"notepad.exe %1"
    local notepad2key=?"C:\Program Files\notepad2\notepad2.exe %1"

    If (how == 0) or (how =="") do    ;;see if key exists
        If (currentvalue == "")do
            messagebox("ok", "It doesn't exist", "Does the 'Open with 
Notepad Key' Exist?")
        Else
            messagebox("ok", "This exists!: "++ sPath++ "\r" ;;+
            ++" '"++currentvalue++"'", "Does the 'Open With Notepad Key' 
Exist?")
        EndIf
    ElseIf (how == 1) do ;;CREATE THIS KEY
        reg.create_key(starshell++openWnp)
        reg.create_key(starshell++openWnp++"\\"++openWnpCmd)
        reg.set_string(sPath, notepadkey)
        messagebox("ok", "okay! This Key was added: 
"++sPath++"\r'"++reg.get_string(sPath)++"'")
    ElseIf (how == 2)do ;;remove key
        reg.set_string(sPath, "")
        reg.delete_value(starshell++openWnp++"\\"++openWnpCmd, "")
        reg.delete_key(starshell++openWnp++"\\"++openWnpCmd)
        reg.delete_key(starshell++openWnp)
        messagebox("ok", "Key Deleted")
    ElseIf (how == 3) do ;;change from Notepad to Notepad2
        reg.create_key(starshell++openWnp)
        reg.create_key(starshell++openWnp++"\\"++openWnpCmd)
        reg.set_string(sPath, notepad2key)
        messagebox("ok", "okay! This Key was added: 
"++sPath++"\r'"++reg.get_string(sPath)++"'")
    EndIf
    quit




[Non-text portions of this message have been removed]

Reply via email to