how to associate file type in window registry for c# program ?
-
Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks
-
Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks
This isn't really a C# question. File associations are stored in HKEY_CLASSES_ROOT/.ext. Most file types then have an almost empty key with the default value pointing to another key (typically 'extfile'). In that key, the default value is the friendly name for the type (appears in Windows Explorer and the File Types dialog). To associate the file type with a program, create a subkey Shell/open/command and for the default value in there, put the command to run (typically something like
path/myapp.exe "%1"
). -
Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks
Have done somethingg similiar. In the code below the file extension to be opened by the app is .stockcheckdata . This extension then needs to be associated with app, in my example the one being opened.
Registry.ClassesRoot.CreateSubKey(".stockcheckdata").SetValue("", "stockcheckdata", RegistryValueKind.String);
Registry.ClassesRoot.CreateSubKey(@"stockcheckdata\shell\open\command").SetValue("", Application.ExecutablePath + " \" %1 \"", RegistryValueKind.String);
Hope it helps?!
-
Hi, I have created a program e.g. test.exe by C#.net and I want to associate file extension (eg .tst) with the test.exe in the window registry. But I found that most commercial program specifying file type in window registry by CLSID, (so the file type may be opened by the program for the dll specifid by the CLSID) which is only for dll. I have only an exe and I can specify opening the file type in the open subKey in the registry. But how can I specify the file type with a dll(CLSID) which in my case I dont have ? or how can I convert my exe into dll so I can open the file type by the dll ? Thanks
Try double-clicking the file and then tell Windows which app to use to open it.