How to modyfy resource in a DLL from this DLL?

白昼怎懂夜的黑 提交于 2019-12-11 07:45:31

问题


I'm writing an add-on for IE using VC++ and ATL. It's a simple DLL and I have a text file that I use as a resource. This answer helped me in doing this.

I have a question about updating resource. MSDN describes how to do it but there is a function (BeginUpdateResource) that need filename of exe or dll with resource.

Is it possible to update resource in my DLL from my DLL? I can easily read it that way, but to update I have to provide DLL's name. Is it necessary?

Also if I won't give full path to my DLL it looks for file on desktop and not where DLL is stored. I don't know why this behave like this.


回答1:


I have never tried to do this so I might be wrong, but I would be surprised if a DLL could update its own resources. If the DLL file is loaded then I would expect the file containing the DLL to be locked for reading and for write attempts to that file to fail.

Still, if you want to try, just have the DLL pass its own path to the function.

You can get your DLL's path using GetModuleFileName by passing your DLL's HINSTANCE / HMODULE (they are the same thing these days) as the first argument. The HINSTNACE / HMODULE is passed to you in DllMain.



来源:https://stackoverflow.com/questions/5065457/how-to-modyfy-resource-in-a-dll-from-this-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!