The custom file generated by the program, such as the suffix is.test
How to start and open the program directly and open this file?
1. Double-click to open
2. Customized file with icon display
3. Right-click to have corresponding properties for custom files
Background code: (How to modify information in the registry)
//Tool startup path string toolPath = + "\\Mail Widget.exe"; string extension = ; string fileType = "Email File"; string fileContent = "text/plain"; //Get information Microsoft. registryKey = Microsoft.(extension); if (registryKey != null && ("shell") != null && ("shell").OpenSubKey("open") != null && ("shell").OpenSubKey("open").OpenSubKey("command") != null) { var varSub = ("shell").OpenSubKey("open").OpenSubKey("command"); var varValue = (""); if ((varValue, toolPath + " %1")) { return; } } //delete Microsoft.(extension, false); //File Registration registryKey = Microsoft.(extension); ("File Type", fileType); ("Content Type", fileContent); //Set the default icon Microsoft. iconKey = ("DefaultIcon"); ("", + "\\"); //Set the default open program path registryKey = ("shell\\open\\command"); ("", toolPath + " %1"); //closure ();
After modifying the registry information, double-clicking the file will start the software. How to operate it in the code?
//Double click to start opening //If there are spaces in the original path, it will be decomposed into multiple elementsif ( > 0) { string filePath = (" ", ()); FileInfo file = new FileInfo(filePath); if () { = ; } }
Then you can do it in the main programloaded
In the method, judgeDoubleClickSptdFilePath
Whether there is a value, if so, get the file under the path and continue the operation.