Announcement

Collapse
No announcement yet.

LoadLibrary and extention

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

  • LoadLibrary and extention

    Guys --
    Somebody knows restrictions for DLL extentions in any OS ? (I don't see problems under Win2000)
    And is it possible to delete "DLL" after LoadLibrary (before FreeLibrary) ?
    I'm interesting in common solution (for all OSes)


    [This message has been edited by Semen Matusovski (edited March 19, 2001).]

  • #2
    Semen;

    I doubt it !

    Windows knows which DLLs are in memory and doesn't allow you to
    modify the file while they are in memory. I know it won't let you
    modify an Exe file that is running, so I would assume the same
    applies to DLLs.

    For example if you compile an app with PB and the app doesn't
    terminate properly, the next time you try to compile you will get
    a "destination file" error, because Windows thinks the app is
    still running. I would guess that Windows is the cause of this and it
    knows what apps are in memory.


    ------------------
    Chris Boss
    Computer Workshop
    Developer of "EZGUI"
    http://cwsof.com
    http://twitter.com/EZGUIProGuy

    Comment


    • #3
      Chris --

      Honestly, I doubt too, but very want.
      I have a program, which updates itself through Internet.
      Files are compressed by zlib and I need to extract them.
      I attach zlib to exe (BTW, directly during compilation).

      During execution, first of sll, I extract zlib from exe, LoadLibrary, then I do not need it.
      Strange, but it looks that after FreeLibrary (at the end of execution) I can't delete DLL also.

      And what about extentions ? Which are allowed everywhere (except dll, exe).

      ------------------
      E-MAIL: [email protected]

      Comment


      • #4
        I wouldn't expect there to be any restrictions on DLL extensions under any
        version of Windows.

        The reason it is not possible to delete a DLL that's still loaded is, the
        file is locked in case the operating system needs to re-read any part of it.


        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          If your goal is to have the DLL clean up after itself, and not
          be left residing on the hard drive, perhaps a suitable compromise
          would be to write it to a small ramdisk, which will at least make
          it volatile.

          ------------------
          Thanks,

          John Kovacich
          Thanks,

          John Kovacich
          Ivory Tower Software

          Comment


          • #6
            Semen, im confused by your query in regards to the extensions part ... you can have an exe or dll named as .anything and you can still use them fine... go to command prompt, rename calc.exe to calc.wayne, and type calc.wayne ... in your WinNT/2K process list you should now see calc.wayne running
            I have a DLL that gets updated regularly in one of my programs, but because of the File-In-Use problem, when my program updates (downloads the new dll) it saves to myfile.tmp instead of myfile.dll. Then, when my program next loads -- before it calls anything in the DLL -- it renames myfile.tmp to myfile.dll... i think FreeLibrary would be the only way to do it without having to restart your program though
            Apologies if i haven't told you anything you didn't already know <grin>


            ------------------
            -

            Comment


            • #7
              Wayne -
              My question appeared after renaming Dll to "a".
              LoadLibrary("a") fails (under Win2000).
              Now I understood - Windows tries to add extention ("a." works)


              ------------------
              E-MAIL: [email protected]

              Comment


              • #8
                Semen,

                If your simply wanting to update your DLLs while your program is
                executing. I would recommend what Computer Associates does with
                InoculateIT.

                They have a ../update directory. To update the virus signature
                and all DLLs I simply copy the files to the ../update
                directory and the next time the program starts up it copies all
                the files from the ../update directory and moves it to the
                /Cheyenne directory, and runs.

                I would recommend that you download all the DLLs to a update
                directory and then the next time your program starts up search
                for the versions of the DLL's, etc etc

                Hope that helps


                ------------------
                -Greg

                [This message has been edited by Gregery D Engle (edited March 20, 2001).]
                -Greg
                [email protected]
                MCP,MCSA,MCSE,MCSD

                Comment


                • #9
                  This may or may not be useful
                  I know an .exe can be renamed while the app is running (on NT ). I am not certain but think a .DLL can also be renamed.

                  Comment


                  • #10
                    How about starting the program from another program
                    or a batch file. When done, let the starting program
                    do the delete.


                    ------------------
                    The world is full of apathy, but who cares?

                    Comment

                    Working...
                    X