rifter1818 Posted November 12, 2004 Posted November 12, 2004 Couple of (hopefully) quick questions here. 1)I've been using Process.Start(filename) to open programs and files fine for a while now however if its a filetype with no known extension is there anyway to open the windows openwith dialoge? or do i have to code my one in which case how do i access the list normally provided by windows in said dialoge. 2)If i was to write a text editor, (C#) how would i access the data from a file opened with my text editor. 3) How would i (through code/ in the setup program) tell windows to use my application for certain file extensions? C# for answers is appreciated but any answer is great thanks in advance. Quote
mskeel Posted November 19, 2004 Posted November 19, 2004 The answers you seek are in the registry. There is a whole slew of keys devoted to known file extensions and what programs use them and such. You can tell windows to use your app with a certian file exension (associate the file extension with you app) when you deploy. It's an option when your putting together your install package. I'm unsure about your first question, but I hope thsese other these thoughts help a bit. They should at least push you in the right direction. Quote
rifter1818 Posted November 20, 2004 Author Posted November 20, 2004 To clarify 1) When you right click on a file and select "Open With" (or double click on a file with an unknown file extension) windows opens up a form with a list of programs and a browse feature to choose what program to open that file with... Just wondering if i can send a filename to that or if i have to code my own. Quote
Joe Mamma Posted November 20, 2004 Posted November 20, 2004 in thge windows sdk (Windows Shell and Controls) Arbitrary File Types Creating a File Association Verbs and File Associations go to pinvoke.net to get c# introp p\invoke code Quote Joe Mamma Amendment 4: The right of the people to be secure in their persons, houses, papers, and effects, against unreasonable searches and seizures, shall not be violated, and no warrants shall issue, but upon probable cause, supported by oath or affirmation, and particularly describing the place to be searched, and the persons or things to be seized. Amendment 9: The enumeration in the Constitution, of certain rights, shall not be construed to deny or disparage others retained by the people.
mcdragon69 Posted December 1, 2004 Posted December 1, 2004 Explorer Icons On this subject, is there a way to read which icons go with which file types? Kind of like a cusom Explorer type app. Can I get the icon definitions from somewhere without having to compile a collection of my own? Quote
joyce11k Posted January 2, 2006 Posted January 2, 2006 i too want an answer to the following question: I've been using Process.Start(filename) to open programs and files fine for a while now however if its a filetype with no known extension is there anyway to open the windows "openwith" dialoge? or do i have to write a code in which case how do i access the list normally provided by windows in said dialoge. If anyone knows an answer to this question, please reply at the earliest possible... Thanx in advance:) Couple of (hopefully) quick questions here. 1)I've been using Process.Start(filename) to open programs and files fine for a while now however if its a filetype with no known extension is there anyway to open the windows openwith dialoge? or do i have to code my one in which case how do i access the list normally provided by windows in said dialoge. 2)If i was to write a text editor, (C#) how would i access the data from a file opened with my text editor. 3) How would i (through code/ in the setup program) tell windows to use my application for certain file extensions? C# for answers is appreciated but any answer is great thanks in advance. Quote
HJB417 Posted January 2, 2006 Posted January 2, 2006 Here's C# code that uses the "open with" dialog. ported from http://blogs.msdn.com/oldnewthing/archive/2004/11/26/270710.aspx and http://groups.google.com/group/microsoft.public.win32.programmer.ui/browse_thread/thread/8dde98bae84136fc/. using System; using System.Runtime.InteropServices; namespace ConsoleApplication6 { [serializable] public struct ShellExecuteInfo { public int Size; public uint Mask; public IntPtr hwnd; public string Verb; public string File; public string Parameters; public string Directory; public uint Show; public IntPtr InstApp; public IntPtr IDList; public string Class; public IntPtr hkeyClass; public uint HotKey; public IntPtr Icon; public IntPtr Monitor; } class Class1 { [DllImport("shell32.dll", SetLastError=true)] extern public static bool ShellExecuteEx(ref ShellExecuteInfo lpExecInfo); public const uint SW_NORMAL = 1; static void OpenAs(string file) { ShellExecuteInfo sei = new ShellExecuteInfo(); sei.Size = Marshal.SizeOf(sei); sei.Verb = "openas"; sei.File = file; sei.Show = SW_NORMAL; if(!ShellExecuteEx(ref sei)) throw new System.ComponentModel.Win32Exception(); } [sTAThread] static void Main(string[] args) { OpenAs(@"C:\odbcconf.log"); return; } } } Unfortunately, I couldn't find a way to prevent the method from returning immediately =( Quote
Mister E Posted January 2, 2006 Posted January 2, 2006 You could also pass in the path to the EXE to the StartInfo property and also specify the path to the file. Most programs will take a file path as a command line argument. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.