DLL unloading itself

后端 未结 4 1387
不思量自难忘°
不思量自难忘° 2020-12-03 16:33

Is it possible for a function that is inside a DLL to unload the DLL? I need to do this so I can make sure the DLL is not in use, then write to the DLL\'s file.

4条回答
  •  抹茶落季
    2020-12-03 16:45

    I don't think it will work. Calling FreeLibrary with a handle from the outside (LoadLibrary would have been called from an area outside the DLL) as the code runs in a memory location that will not be valid anymore.

    Even if this is possible, it smells like a bad design. Maybe you want to make some updater or alike. Explain a bit more what is the result you expect. Unloading a DLL from within itself is not the way to go.

提交回复
热议问题