开发者

How to modyfy resource in a DLL from this DLL?

开发者 https://www.devze.com 2023-02-12 22:31 出处:网络
I\'m writing an add-on for IE using VC++ 开发者_如何学JAVAand 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'm writing an add-on for IE using VC++ 开发者_如何学JAVAand 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号