Solved

Associating

Posted on 2000-04-16
3
347 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
Comment Utility
0
 
LVL 17

Expert Comment

by:inthe
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…
This video discusses moving either the default database or any database to a new volume.

743 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