CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8
  1. #1
    Join Date
    Jun 2003
    Posts
    299

    Associating extension with my application

    hi,

    with my VB application, i create files with extention ".myext". LEts say i created a file called abc.myext. Now, when i double click on the abc.myext, it should launch my application. I know I can do this manually by associating the extention with the application. But for my users, i dont expect them to know this. Is there a way i can do this programmatically...?

    Thanks!

  2. #2
    Join Date
    Feb 2001
    Location
    PA
    Posts
    163
    You could try creating a batch file using the ASSOC command to associate files and then call the batch file in your program. Never tried this so I can't guarantee anything.

    Cubbie

  3. #3
    Join Date
    Jun 2003
    Posts
    299
    would you be knowing the command or someplace to look how to associate extensions with application????

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    At least three places:

    1)
    http://www.codeguru.com/forum/showth...ight=associate
    -------------------------------------------------------------
    2)
    (The following should be really clear for your purpouse
    http://www.**************/Item.asp?Pa...odeBank&ID=334
    -------------------------------------------------------------
    3)
    http://www.mvps.org/vbnet/code/reg/association.htm
    Last edited by Cimperiali; August 19th, 2003 at 04:44 PM.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Jun 2003
    Posts
    299
    I was successful in associating the file extention with my application. I created an entery called ".myext" under HKEY_CLASSES_ROOT pointing to MyApp.Document.

    Created another entry under HKEY_CLASSES_ROOT called MyApp.Document.

    Under MyApp.Document created two keys:
    \shell\open\command : "path to my exe" %1
    \DefaultIcon": "path to my exe",1

    Still whenver i create file with extention ".myext" it is associated correctly with my application, but the icon appearing next to the file is not the icon of my applicaiton, i think it is the icon of the wordpad file.

    any idea how to display the icon..

    Thanks!

  6. #6
    Join Date
    Apr 2003
    Posts
    1,755

    Smile

    Try to add "-" (negative sign) before the icon number

    "path to my exe",-1

    Hope it will help you

  7. #7
    Join Date
    Jun 2003
    Posts
    299
    i had to use :

    SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0

    from my application to notify other windows. But the problem is when i uninstall my program, the icon in front of the files created with my application still remains. i have to logout or something like that to remove it..is there an easier way to remove the icon..

  8. #8
    Join Date
    Jun 2003
    Posts
    299
    The file association does not work on XP...is there a different wayt to associate the extention to the application on XP.

    I was successful in associating the file extention with my application on W2K. I created an entery called ".myext" under HKEY_CLASSES_ROOT pointing to MyApp.Document.

    Created another entry under HKEY_CLASSES_ROOT called MyApp.Document.

    Under MyApp.Document created two keys:
    \shell\open\command : "path to my exe" %1
    \DefaultIcon": "path to my exe",-1

    But the baove procedure doe snot work on XP. Any idea??

    Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured