I don't really know what happens, partially because you did not define 'failed'.
I would start by modifying these two lines:
App.CreateSubKey("shell\\open\\command").SetValue("", "\"" + Application.ExecutablePath + "\" \"%1\"");
App.CreateSubKey("shell\\edit\\command").SetValue("", "\"" + Application.ExecutablePath + "\" \"%1\"");
This way, both the executable path and the command-line arguments will be enclosed between their own quotes.