Need Help With Code Please.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Quantrac
    Indigo Rose Customer
    • Jan 2004
    • 33

    Need Help With Code Please.

    I'm not very good with this programming stuff, so if anyone could please help me with a code I need, it would be greatly apprciated. Everything I try I always get a build failed error. This is what I am needing.

    Renaming a file comctl32.ocx located in the system folder for all windows versions. Rename it to something like comctl32_backup.ocx. Then I would like it to copy comctl32.ocx from the autoplay root to the windows system folder (All windows versions). When it has finished replacing the file a status dialog message saying the update has completed.

    I hope this is simple for someone to help me with. You can email me the code at [email protected].

    Thanks so much.

    Amy
  • Worm
    Indigo Rose Customer
    • Jul 2002
    • 3971

    #2
    A couple things to be aware of here. It is not generally a good idea to replace an OCX file with another unless you sure that you are replacing with a newer version of the OCX. Replacing with an older OCX can cause you many problems in other apps. Especially this particular OCX since it is part of the Windows Common Controls.

    Also, if the file is in use by any Windows App, you won't be able to replace/rename it until they are closed.

    Since its an ActiveX control, it'll need to be registered with the OS if in fact you do replace the original.

    Do you mind if I ask what you are trying to accomplish?
    (besides the obvious anyway)

    Comment

    • Quantrac
      Indigo Rose Customer
      • Jan 2004
      • 33

      #3
      Our problem is that other software programs that our customer has installed, is replacing this ocx file with an older version that our's is not compatible with. I am fully aware that it could effect other software, but in our industry our customer's value our software far more than any other they are using and are will to take the chance. After putting more thought into this, I think it would be a good idea to have an addition code that would reverse the whole thing just in case. Can you help me with this?

      Thanks so much for your time.

      Amy

      Comment

      • Worm
        Indigo Rose Customer
        • Jul 2002
        • 3971

        #4
        Code:
        if File.DoesExist(_SystemFolder .. "\\Comctl32_old.ocx") then
        	File.Delete(_SystemFolder .. "\\comctl32_old.ocx", false, false, false, nil)
        end
        
        if File.DoesExist(_SystemFolder .. "\\comctl32.ocx") then
        	File.Rename(_SystemFolder .. "\\comctl32.ocx", _SystemFolder .. "\\comctl32_old.ocx");
        end
        
        error=Application.GetLastError();
        if error ~= 0 then
        	result = Dialog.Message("Error", "Please close all applications and try again.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
        else
        	File.Copy("AutoPlay\\Docs\\comctl32.ocx", _SystemFolder .. "\\comctl32.ocx", false, true, false, false, nil);
        	Application.Sleep(1);
        	File.Run("regsvr32.exe", "/s" .. _SystemFolder .. "\\comctl32.ocx", "", SW_MINIMIZE);
        end

        Comment

        • Stefan_M
          Indigo Rose Customer
          • Nov 2003
          • 315

          #5
          in addition to Worms code you should check if there is a never version bevor you start copying your file.

          Your_OCX_Version="6.0.81.5";
          Version = File.GetVersionInfo(_SystemFolder.."\\comctl32.ocx ");
          if (String.CompareFileVersions(Your_OCX_Version, Version.FileVersion))>=0 then

          --Start copy

          end


          Stefan
          "With a rubber duck, one's never alone."

          Douglas Adams, The Hitchhiker's Guide to the Galaxy

          Comment

          • Worm
            Indigo Rose Customer
            • Jul 2002
            • 3971

            #6
            I thought the same, but she implied that the version she was putting in place was "the" version to have in place for the software, so I skipped the check.

            Comment

            • Stefan_M
              Indigo Rose Customer
              • Nov 2003
              • 315

              #7
              Your right, but replacing a newer version with an older is never a good idea and should not be done.
              "With a rubber duck, one's never alone."

              Douglas Adams, The Hitchhiker's Guide to the Galaxy

              Comment

              • Worm
                Indigo Rose Customer
                • Jul 2002
                • 3971

                #8
                I agree whole heartedly and indicated that in my first reply.

                Amy said
                I am fully aware that it could effect other software, but in our industry our customer's value our software far more than any other they are using and are will to take the chance.

                Comment

                • Quantrac
                  Indigo Rose Customer
                  • Jan 2004
                  • 33

                  #9
                  Thanks for your help!

                  Thank you for all of your help. I was able to get what I needed. You guys were great!

                  Have a good day.

                  Comment

                  Working...
                  X