Solved

Associating

Posted on 2000-04-16
3
351 Views
Last Modified: 2013-12-03
Hello experts.

I'd need help.
I'm trying to make a setup for my program.
Well... What I need exactly is to associate a file extension to my program (Not the setup :-) and program icon.
Lets assume the name of the program is "Program1.Exe", and the extension is ".Cir", And the name of the icon is "PrgIcon.Ico".

From this moment and on, when the user dclicks a file with extension "Cir", I want Windows to run my program with this command line "C:\path\FileName.Cir"

By the way, using Install Shield to make the setup program
There is a script sample but is not clear for me

Thanks.
0
Comment
Question by:Marsc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 70 total points
ID: 2721119
0
 
LVL 17

Expert Comment

by:inthe
ID: 2721132
knowledge base article from InstallShield's support site at http://support.installshield.com
 
 
*** InstallSite provides free resources for setup developers at
*** http://www.geocities.com/SiliconValley/Peaks/5537/
 
 
HOWTO: Associating a File Extension with my Application's Executable Files Document ID: Q101360
This article applies to the following:
Product(s): InstallShield 5.0 Professional build 221 and earlier, InstallShield 5.0 Free Edition build 221 and earlier, InstallShield 5.0 Professional International West Edition build 219 and earlier
Last Revised On: 10/24/1997
Summary
How can I associate data files with my application's executable files such that when a user opens one of my data files, my application will be executed?
 
----------------------------------------------------------------------------
----
 
Discussion
To associate a data file with an executable, you must register its file extension to point to your application's executable. You can create a file association from your setup script using the following method. Note that file associations created using this method will uninstall correctly on all platforms.
1. (Optional) Call the RegDBKeyExist function to determine whether an association already exists for the file type (extension) you are registering. If an association exists, there will be a root-level key for that file type under HKEY_CLASSES_ROOT. The root-level key may contain other subkeys or a reference to another root-level key that contains registration information. If your setup detects that this key exists, you may want to display a warning message for the end user before replacing this key. 2. Call the RegDBCreateKeyEx function to create the following key structure under the HKEY_CLASSES_ROOT key:
..ext\\shell\\open\\command
where .ext is the file extension being registered (including the period) Use separate calls to RegDBCreateKeyEx to create each key, as in the example below, so that these keys will be logged properly for uninstallation. 3. Call the RegDBSetKeyValueEx function to update the default value under the newly created command key. The default value for the key should contain the complete path and file name of the application's executable, followed by the string "%1".
Note: This section of the registry can be read by 16- or 32-bit
applications. Therefore, in a 32-bit setup it is recommended that you call the LongPathToShortPath function to convert the path to its short path equivalent before adding the value to the registry.
 

and i just knicked this example off a newsgroup:

The following example associates the .zzz file extension with Notepad.exe:
#define EXTENSION ".zzz"
BOOL bResult;
LONG lResult, lDisk;
STRING szPath;
program
    bResult = RegDBKeyExist(EXTENSION);
    if (bResult = TRUE) then
        lResult = AskYesNo ("Warning the extension (.zzz) is already registered. Overwrite?", YES);
        if (lResult = NO) then
          abort;
        endif;
  endif;
    szPath = WINDIR ^ "Notepad.exe %1";
    LongPathToShortPath (szPath);
    RegDBCreateKeyEx (EXTENSION, "");
    RegDBCreateKeyEx (EXTENSION + "\\shell", "");     RegDBCreateKeyEx (EXTENSION + "\\shell\\open", "");     RegDBCreateKeyEx (EXTENSION + "\\shell\\open\\command", "");   RegDBSetKeyValueEx (EXTENSION + "\\shell\\open\\command", "", REGDB_STRING, szPath, -1);
endprogram
 
0
 
LVL 1

Author Comment

by:Marsc
ID: 2723812
Thanks Chensu...

And Thanks to Inthe to.
You deserve points to... but you know...
E-E doesn't support points divition :-)

Thanks anyway.




0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question