Solved

Associating

Posted on 2000-04-16
3
348 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

910 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now