开发者

How to extract a resource from within a BPL?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜