Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. FindResource

FindResource

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelpannouncementlearning
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sparticus
    wrote on last edited by
    #1

    Okay, I'm trying to load the raw data of a resource of a custom type. I've named the type "JPG" and have created a resource with the ID "IDR_JPG1". The resource is located within the executable. The code that I've come up with is: char* pData = 0; HRSRC hRsrc; HGLOBAL hGlobal; DWORD dWord; hRsrc = FindResource( NULL, ?, RT_RCDATA ); dWord = GetLastError(); // Produces 1813 (ERROR_RESOURCE_TYPE_NOT_FOUND) hGlobal = LoadResource( NULL, hRsrc ); pData = (char*)LockResource( hGlobal ); I have no idea what I need to be putting in place of the question mark. The MSDN Library provides only unclear and essentially useless information. Also, I'm a little uneasy about locking up a resource and not releasing it. Do I need to release it? There is a FreeResource function but I'm told that it is depricated. I'd appreciate any info you could send my way.

    S 1 Reply Last reply
    0
    • S Sparticus

      Okay, I'm trying to load the raw data of a resource of a custom type. I've named the type "JPG" and have created a resource with the ID "IDR_JPG1". The resource is located within the executable. The code that I've come up with is: char* pData = 0; HRSRC hRsrc; HGLOBAL hGlobal; DWORD dWord; hRsrc = FindResource( NULL, ?, RT_RCDATA ); dWord = GetLastError(); // Produces 1813 (ERROR_RESOURCE_TYPE_NOT_FOUND) hGlobal = LoadResource( NULL, hRsrc ); pData = (char*)LockResource( hGlobal ); I have no idea what I need to be putting in place of the question mark. The MSDN Library provides only unclear and essentially useless information. Also, I'm a little uneasy about locking up a resource and not releasing it. Do I need to release it? There is a FreeResource function but I'm told that it is depricated. I'd appreciate any info you could send my way.

      S Offline
      S Offline
      Sparticus
      wrote on last edited by
      #2

      Okay, to answer my own question . . . hRsrc = FindResource( NULL, MAKEINTRESOURCE( IDR_JPG1 ), "JPG" ); Corrects the problem

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups