Announcement

Collapse
No announcement yet.

Anyone familiar with file associations?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Anyone familiar with file associations?

    I want a button where when you click on it, it sets a certain file extension to open with a certain program.

    Any ideas? I got it to where it adds the program to the "recommended applications to open with this extension" list, but I can't get it to physically make the program the default to run that extension.

    Any help would be great.

  • #2
    Re: Anyone familiar with file associations?

    I believe those associations are controlled by registry entries. You should be able to set the default associations there. BUT I am one of those people that does not like it when a program changes my file associations. I actually Hate it. But that is me. I will look in the registry to see if I can find the entries.
    TJ-Tigger
    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools."
    "Draco dormiens nunquam titillandus."
    Map of IR Forum Users - IR Project CodeViewer - Online Help - TiggTV - QuizEngine

    Comment


    • #3
      Re: Anyone familiar with file associations?

      Well thats the whole deal, i'm making it an OPTION in my AMS application. if they click a button, it will associate the program with that extension.. if they click another button, it will de-associate it and renew the previous configuration

      Comment


      • #4
        Re: Anyone familiar with file associations?

        Here is some VB Code that I've used for file associations. I know its VB, but you should be able to break it down fairly easy.

        'See if our file extension already exists:
        If GetString(HKEY_CLASSES_ROOT, ".i01", "Content Type") = "" Then
        'Nope - not added yet. Register the file type:

        'create an entry in the class key
        Call SaveString(HKEY_CLASSES_ROOT, ".i01", "", "Mini Estimate")
        'content type
        Call SaveString(HKEY_CLASSES_ROOT, ".i01", "Content Type", "text/plain")
        'name
        Call SaveString(HKEY_CLASSES_ROOT, "Mini Estimate", "", "Intec Mini Estimate file")
        'edit flags
        Call SaveDWord(HKEY_CLASSES_ROOT, "Mini Estimate", "EditFlags", "0000")
        'file's icon (can be an icon file, or an icon located within a dll file)
        'in this example, I am using a resource icon in this exe, 0 (app icon).
        Call SaveString(HKEY_CLASSES_ROOT, "Mini Estimate\DefaultIcon", "", App.Path & "\" & App.EXEName & ".exe,0")
        'Shell
        Call SaveString(HKEY_CLASSES_ROOT, "Mini Estimate\Shell", "", "")
        'Shell Open
        Call SaveString(HKEY_CLASSES_ROOT, "Mini Estimate\Shell\Open", "", "")
        'Shell open command
        Call SaveString(HKEY_CLASSES_ROOT, "Mini Estimate\Shell\Open\Command", "", App.Path & "\" & App.EXEName & ".exe %1")
        'Update the Windows Icon Cache to see our icon right away:
        SHChangeNotify SHCNE_ASSOCCHANGED, SHCNF_IDLIST, 0, 0

        End If

        Comment


        • #5
          Re: Anyone familiar with file associations?

          Worm, is there anything you CAN'T do? [img]/ubbthreads/images/icons/smile.gif[/img]

          Thanks so much

          Comment


          • #6
            Re: Anyone familiar with file associations?

            what dll does the SHChangeNotify function need to be called from? user32?

            Comment


            • #7
              Re: Anyone familiar with file associations?

              Can't seem to get an Application's button to NOT appear in the taskbar. It's driving me nuts. And OH So many other things.

              Comment


              • #8
                Re: Anyone familiar with file associations?

                Shell32.dll

                Comment


                • #9
                  Re: Anyone familiar with file associations?

                  Worm, this might be of some help:


                  Managing Taskbar Buttons
                  The Shell creates a button on the taskbar whenever an application creates a window that isn't owned. To ensure that the window button is placed on the taskbar, create an unowned window with the WS_EX_APPWINDOW extended style. To prevent the window button from being placed on the taskbar, create the unowned window with the WS_EX_TOOLWINDOW extended style. As an alternative, you can create a hidden window and make this hidden window the owner of your visible window.

                  The Shell will remove a window's button from the taskbar only if the window's style supports visible taskbar buttons. If you want to dynamically change a window's style to one that doesn't support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window.

                  The window button typically contains the application icon and title. However, if the application does not contain a system menu, the window button is created without the icon.

                  If you want your application to get the user's attention when the window is not active, use the FlashWindow function to let the user know that a message is waiting. This function flashes the window button. Once the user clicks the window button to activate the window, your application can display the message.

                  Modifying the Contents of the Taskbar
                  Version 4.71 and later of Shell32.dll adds the capability to modify the contents of the taskbar. From an application, you can now add, remove, and activate taskbar buttons. Activating the item does not activate the window; it shows the item as pressed on the taskbar.

                  The taskbar modification capabilities are implemented in a Component Object Model (COM) object (CLSID_TaskbarList ) that exposes the ITaskbarList interface (IID_ITaskbarList ). You must call the HrInit method to initialize the object. You can then use the methods of the ITaskbarList interface to modify the contents of the taskbar.


                  The actual link

                  that might help... read the last sentence i bolded

                  Comment


                  • #10
                    Re: Anyone familiar with file associations?

                    Been down that road. Seems that when the window gets focus the button magically reappears. Thanks for the info though.

                    Comment

                    Working...
                    X