No announcement yet.

File association (custom file types)

  • Filter
  • Time
  • Show
Clear All
new posts

  • File association (custom file types)


    I am running into a problem when using the code provided from this discussion.
    I see there in the function a parameter missing when calling Registry.SetValue:

    function File.SetAssocation64(cExt, cExe, cIcon, cShort,cLong)
        -- Set the file association for the given file.
        Registry.SetValue(HKEY_CLASSES_ROOT, cExt, "", cKey);
        Registry.SetValue(HKEY_CLASSES_ROOT, cKey, "",cLong);
        Registry.SetValue(HKEY_CLASSES_ROOT, cKey.."\\DefaultIcon","",File.GetShortName(cIcon)..",0");
        Registry.SetValue(HKEY_CLASSES_ROOT, cKey.."\\shell\\open\\command", "", "\""..cExe.."\" \"%1\"");

    Registry.SetValue takes 5 parameters, but the provided code from the discussion uses only 4. How can this code work with the missing parameter??

    Shouldn't be the TYPE given?

    My problem is, that I need to change the code for the WOW64 alternative for 64 bit OS.

    In this case I only have to add Wow64.KEY64 as 6th parameter. But in the original code above, a whole parameter is missing.... I don't know which one and I don't know how this code should even work.

    Thank you in advance!

  • #2
    Get Ulrich's wow64/registry plugin (off and adjust the code as needed.


    • #3

      yes, that is the Plug in I am using.
      But it does not work. And I think it is because the example is not correct.

      Ulrich's plug in takes 6 parameters. The standard SetValue needs 5 parameters.
      But the code example above sets only 4. So one parameter is missing in the example.
      My question is: How can this work?

      I think there is a mistake.


      • #4
        Adapt it to your needs. His plugin does work.


        • #5
          You don't get me.

          Have a look at this function:
          Registry.SetValue(HKEY_CLASSES_ROOT, cExt, "", cKey);

          There, the type is missing as 5th parameter.
          I am asking, how the code should work when it is obviously not complete?

          Shouldn't it be:
          Registry.SetValue(HKEY_CLASSES_ROOT, cExt, "", cKey, [B]REG_SZ[/B]);
          Last edited by AutoPlayUser; 10-01-2013, 05:47 AM.


          • #6
            Oh, I get you -- you should rtfm...

            Registry.SetValue ( 
             number MainKey,
            string SubKey,
            string Value,
            string Data,
            number Type = REG_SZ )
            I only see 4 required parameters.


            • #7
              As you can see in my first post, I linked that reference to that function. So you can assume that I read it!
              The description is not clear. I see 5 parameters with no "optional" hint. Sth. like "default = REG_SZ when missing" should be the correct form!


              • #8
                t'is pretty standard documentation to indicate an optional value. Did you try the code? So far it seems that you are wanting there to be a problem ... telling me there's a problem with my code, but then referencing something unrelated (your need for wow redirection or not); but not telling me what, exactly, is the problem you have with my code, isn't a smooth path to finding you a resolution...
                The code works, the documentation is correct. If you need wow redirection, you can adapt the code easily to use Ulrich's registry functions.


                • #9
                  Your code works, thank you.


                  • #10
                    Originally posted by AutoPlayUser View Post
                    Your code works, thank you.
                    So is was the problem, if not the code...