Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7696063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:41:34+00:00 2026-05-31T21:41:34+00:00

I want to make a component that uses some resources compiled in my package’s

  • 0

I want to make a component that uses some resources compiled in my package’s project. My component will try to use this resource (a PNG image) during runtime (at its constructor).

I want to use it in my application’s project, but as soon as the component gets created, I get the following exception:

First chance exception at $7579B9BC. Exception class EResNotFound with message 'Resource xxx not found'. Process yyy.exe (6060)

What am I missing here?

EDIT

The calling code for the resource in the package’s project is like this:

Png.LoadFromResourceName(HInstance, 'png_resource_name');

EDIT 2

As suggested by David, I tried using the function GetModuleHandle, but it will always return 0 if I call it from the package’s project or the application’s project. The code being called in the package’s project is like this:

PackageModuleHandle := GetModuleHandle(PChar('my_package.bpl'));
Png := TPngImage.Create;
Png .LoadFromResourceName(PackageModuleHandle, 'png_resource_name');

Absolute paths to the bpl file won’t work either.

EDIT 3

New attempt based on new answer:

PackageModuleHandle := FindClassHInstance(TMyComponent);
Png := TPngImage.Create;
Png .LoadFromResourceName(PackageModuleHandle, 'png_resource_name');

Fails with the same exception.

EDIT 4

Using ResourceHacker, and if I used it right, the resources doesn’t seem to be in my bpl file. What could I be doing wrong about this? Seems such a complicated matter to such a simple feature.

CONCLUSION

I had to add the .res file of my package to the package’s .dpr just after the {$R *.res} line. Like this:

{$R *.res}
{$R 'my_pacakge.res'}

Also, I had to include the my_package.rc file to my project, so the resources would get compiled to the .res after each build. That did the trick, I guess. Thanks for all the answers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T21:41:35+00:00Added an answer on May 31, 2026 at 9:41 pm

    You need to use FindClassHInstance(), specifying your component’s class type, instead of using the global HInstance variable or GetModuleHandle(). That way, you obtain the correct module handle regardless of whether the package gets statically linked or dynamically linked into the main executable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to make a component that they can use like this [following] they
I want to use Gama component in Android to make our app good.I have
I want to make a UI like this image https://i.stack.imgur.com/bB8UM.png .I use the basic
I have a component and I want to make a textarea on the admin
I want make datetimepicker in my project. Using jquery how it is possible? I
Let's say I want make some of my sources publicly available via my blog
I want to have a component that looks like a button, but instead of
At the moment, our application uses the Trident Win32 component, but we want to
I'm trying to debug a native application that uses some C# components but I'm
I want to create a panel (or any other component) inside a component that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.