开发者

How to extract a resource from within a BPL?

开发者 https://www.devze.com 2023-02-18 11:45 出处:网络
If I\'ve got a resource in an EXE and I want to extract it, it\'s pretty simple.Something like: stream := TResourceStream.Create(HInstance, ResourceName, RT_RCDATA);

If I've got a resource in an EXE and I want to extract it, it's pretty simple. Something like:

stream := TResourceStream.Create(HInstance, ResourceName, RT_RCDATA);

This works because the global variable HInst开发者_如何学Pythonance is a handle to the EXE. Is there any similar way for code within a BPL to get a handle to the package it's a part of so I can extract a resource from it?


HInstance is actually in the SysInit unit which is unique for each PE (package, exe, dll). System, where the bulk of the compiler RTL and helper functions live is shared among packages if using the rtl package.

So, the code you showed above should work fine from within a package. MainInstance is probably what you're thinking of as being the handle to the loading exe (or even DLL in some cases).

0

精彩评论

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

关注公众号