 |
|
 |
If the user has specified another default application (via the 'Always Open With' dialog), this code does not work. In this case you need to delete the key stored under HKCU\Software\Microsoft\Windows\Current Version\Explorer\FileExts\.txt\UserChoice
|
| Sign In·View Thread·PermaLink | 1.00/5 (2 votes) |
|
|
|
 |
|
 |
I have tried to open file, using CStdioFile::Open with options CFile::modeRead | CFile::shareDenyNone, but gives an error. The message error is strange "No error occurred" What could be? Tks
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Ok - this may be irrelevant but does anyone know how to do a similar thing inside a Delphi project? I am a newbie and trying to make my Delphi application automatically recognise file types as its own on Windows explorer.
http://theprecociousone.spaces.live.com/
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Great article, I have done what you suggested and I can get my application to receive the file name when the user clicks on the file and my application is NOT running.
However, when my application is running and the user clicks on a file, my application does not receive any notification that a file open command was issued ?
Any ideas ?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
 |
Usefull stuff, Blake! Here is a simple C# version, to be adapted to your needs (check extension pre-conditions etc):
using Microsoft.Win32;
public static void Associate(string extension, string progID, string description, string icon, string application) { Registry.ClassesRoot.CreateSubKey(extension).SetValue("", progID); if (progID!=null && progID.Length>0) using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(progID)) { if (description!=null) key.SetValue("", description); if (icon!=null) key.CreateSubKey("DefaultIcon").SetValue("", ToShortPathName(icon)); if (application!=null) key.CreateSubKey(@"Shell\Open\Command").SetValue("", ToShortPathName(application) + " \"%1\""); } }
public static bool IsAssociated(string extension) { return (Registry.ClassesRoot.OpenSubKey(extension, false)!=null); }
[DllImport("Kernel32.dll")] private static extern uint GetShortPathName(string lpszLongPath, [Out] StringBuilder lpszShortPath, uint cchBuffer);
private static string ToShortPathName(string longName) { StringBuilder s = new StringBuilder(1000); uint iSize = (uint) s.Capacity; uint iRet = GetShortPathName(longName, s, iSize); return s.ToString(); }
Call pattern:
if (!IsAssociated(".ext")) Associate(".ext", "ClassID.ProgID", "ext File", "YourIcon.ico", "YourApplication.exe");
|
| Sign In·View Thread·PermaLink | 3.20/5 (4 votes) |
|
|
|
 |
|
 |
Hi
I have a question about the call pattern:
if (!IsAssociated(".ext")) Associate(".ext", "ClassID.ProgID", "ext File", "YourIcon.ico", "YourApplication.exe");
From where do I get the value ClassID.ProgID? What is that? 
Thank you, Dominik
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
ClassID.ProgID is the identifier of an ActiveX/COM component (see spec).
I'm not sure, but it seems that an application must be registered as COM to make this kind of file association possible (?)
|
| Sign In·View Thread·PermaLink | 2.50/5 (2 votes) |
|
|
|
 |
|
 |
I had, like others in this thread, the "long files names" problem. If the executable file was in a long path, the launched document is passed as argument in 8.3 format to the program.
It was, as others said, caused by the lake of quotes arround the executable file name.
Just in case, for others, it works by replacing :
// just pass file path in quotes on command line csTempText = szProgPath; csTempText += " \"%1\"";
by
csTempText.Format("\"%s\" %s",szProgPath,"\"%1\"");
Wich adds quotes arround the executable path.
By this way, if the executable file is in long file name path or not, windows will pass the good long file name of the document in m_lpCmdLine
|
| Sign In·View Thread·PermaLink | 4.00/5 (1 vote) |
|
|
|
 |
|
 |
OK, every thing is fine. but can you help me finding a way to check the association? i have to check the association for an extention first with my app. if it is associated with some other app, i have to prompt user and then register it with app if wanted.
Thanx,
Ahmed: a dreaming soul.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
thanks for the great discussion. i have a beginner's question: what determines the icon index sent to SetDocumentDefaultIcon()? i understand that the application's icon is 0, but that's about it. if you know of a tutorial describing how to set these icon-document/application associations, i'd appreciate it. thanks, ed
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
It is EXACTLY the order they are located in the resources.
You have to carefully order the ICON statments in the RC file if you want the icons to have a particular index.
So, when the index is set to 0, it is typically because the desired icon is the first one, or in some cases, the only one in the EXE file.
If you wanted the third icon in the EXE file's resources to be the applcication icon, then use an index of 2, for exmaple.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
This was a very useful information for my running project. Thanks a lot.. Regards
Sreekanth Muralidharan, Corporate Systems Consultant [Embedded Systems], INDIA
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I noticed that after a file type was registered. One-clike on the files with the spec type direct to our program as predicted. But if the file type was associated by another program before we take the change. The file's icon will not refresh to the one we specified automatically in the Explorer. Is there any way to tell windows do that for us?
Best Regards, Michael Leung
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
|
 |
|
 |
How can we pass all the selected files to a running application ?? When I use open command, each file opens a new App. window.
ie. I'd like to write a program like WinMedia Player. We Right-Click --> "Add to Now Playing List" : all the selected files are added to only ONE App. window.
Please help me out this problem, I desperately need it. Thanks so much !!
A true luv is obviously eternal !!
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
If you completely control the program then what you do is actualy run another copy of the program. The second copy of the program passes the file to the first copy of the program and then exits. You can use WM_COPYDATA or else a memory mapped file to pass the data or some other means of interprocess communication. You also pass a flag on the command line to the program so you can disntinguish that the intention is to pass the file from the second program to the first program. This way, if the user actually starts your program with his own command and passes a file, you DO get a second copy running the second file, as the user would expect. You can't force a program to accept more than one file if it was not originaly designed to do so. I think there might be a sample of passing a file from one instance of a program to another on this website.
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
 |
|
 |
This mght require some kind of MIME association, but I have not investigated that. Perhaps you can find something similar in the registry for types that DO work within IE.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Please forgive a beginner's very basic question. I have included the files cgfiltyp.cpp and .h in my project and set registry keys to recognise my app from the extension. But when - in my app - I try to get from the command line (from m_lpCmdLine) the full pathname of the file on which I have double-clicked, it comes back in the form
"C:\MYFOL~1\MYFIL~1.XXX"
as opposed to C:\MyFolder\MyFile.xxx
As far as I can see, the registry keys are set as in your demo, with the exception of CLSID. Any assistance gratefully appreciated!!
Brian
|
| Sign In·View Thread·PermaLink | 1.00/5 (1 vote) |
|
|
|
 |
|
 |
These are the 'short' file names. Your system might be set up to convert long file names to short ones automatically.
Please read some more in the MSDN (April 2004) here : Files and I/0 Technical Articles : Making Room for Long Filenames
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
I had a similar problem. What makes a difference seems to be how the text is quoted in the registry. This worked for me:
Shell\Open\Command key: The default value must look like this in regedit:
"C:\folder 1\folder 2\My App Name.exe" "%1"
Aldo
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |