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 make a table in SqlServer that will add, on insert, a
I want to make a component that includes a list of integers as one
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 make an etag that matches what Apache produces. How does apache
I want to make an entity that has an autogenerated primary key, but also
I want to make my component faster, I am using Javascript and JQuery to
At the moment, our application uses the Trident Win32 component, but we want to

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.