Results 1 to 8 of 8

Thread: associating file types- how?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    associating file types- how?

    I want to make my program to be the default app for a file type......give me a hint plz
    Last edited by MrPolite; Jul 7th, 2002 at 11:38 PM.

  2. #2
    Member
    Join Date
    Aug 2001
    Location
    nr Manchester, England
    Posts
    34
    I think you'll have to use some API calls here

  3. #3
    Member
    Join Date
    Aug 2001
    Location
    nr Manchester, England
    Posts
    34
    I think you'll have to use some API calls here

  4. #4

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    well how btw .NET should be able to do it, no APIs I guess

  5. #5
    hellswraith
    Guest
    You shouldn't need an API call, I think that stuff is stored in the registry.

    Here is about the closest thing I have found, and it just happened to show up in the MSDN Flash newsletter in my email box today...what timing. Anyway, it might get you started on where to look.
    http://msdn.microsoft.com/library/de...teringapps.asp

  6. #6
    Member
    Join Date
    Jul 2002
    Posts
    49
    Okay, I was waiting for someone else to tell you how since its quite long and annoying but since no one has told you yet, I'll have a go.

    There are two ways of setting file associations in vb, the easy way, getting a setup project to do it for you, or the hard way, doing it manually. Both of which I haven't used in a while, so I'm a little rusty.

    First the hard way
    Open regedit.exe to look at your system registry. In HKEY_CLASSES_ROOT you will find all the file extensions you currently have associated, say ".psp" for example. Open that key and you find its file type "PSP7.Image", now if you scroll down somewhere underneath the file extensions you will find this file type. Open this key and under "shell" you will find the actions that can be performed on the file. Usually there will only be "open", under that you will find the "command" key and in that is the command that windows carries out on the file. For this file it would have some thing like ("C:\Program Files\PSP7\psp7.exe" "%1") where "%1" will be substitued for the file path you just clicked. So to replicate this behaviour you just need to make your own registry keys and entries, but you also need to handle the filename that is passed to your program. This is exposed via the "Microsoft.VisualBasic.Command" so all you have to do is make your program check for this at startup and load the file that is provided.

    Anyway, the easy way of associating files is to use a setup project. Add a setup project to your solution and then go to the "Project" menu, click 'add' then from the dialog window add the primary output of your current project. Now you have the basis of a setup project. Now go to the "File Types Editor" window and add a new document type. Set the description, extension and icon properties as desired and set the command property to the primary output of the project you just added.

    Now theoretically when you install the project on someone elses computer it will automatically associate its self with the extension you provided. I say theoretically because I haven't actually tried this with the .net install project, I've only worked with install shield and similar applications.

    I hope this wasn't too confusing. If you have any problems or questions email me and I'll try to help.

  7. #7

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    tnx Matt02 and hellswraith!
    I didnt read the article hellswraith, because it said that it only applied to WINXP and 2k (XP for some parts), but thanks alot anyways

  8. #8
    Addicted Member Buy2easy.com's Avatar
    Join Date
    Jul 2002
    Posts
    200
    in vb.net how do you know if the program was started by an associated file type or if it was just opened with the .exe file?

    Any help would be great!

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