title: FindResource() fails to find data even though data is in exe
body: <p>I have been all over this one, and I am just plumb stuck.  I have been building a project and I want to embed a text file as a resource into the executable.   I understand all the basics of how this "should" work, but for some reason it is not.  So, let me start from what I have so far and maybe the problem can be pinned down.</p>
  
  <p>There are two functions here, the first, EnumResNameProc was an attempt to debug the problem my self, the second, LoadFileInResource is the function I am trying to get working.
  It is a little messy because I was in the middle of building it when I starting having problems.</p>
  
  <p>The exact issue is, FindResourceExA is returning NULL, and I am lost as to the exact reason.  I know it is an error, and the return code is 1813, "Resource Not Found". </p>
  
  <p>I have other resources in this project, I have a version node, a mainifest node, (of which, I am not directly reading)  I have an icon node (that I am applying to my window system menu icon) and a bitmap (that I am loading as a texture.).  These all have defined types, for example, the type for the Bitmap is 12.  Now, I am attempting to load a text file, with is a 'user defined' type of 10.  I know the data is INSIDE the executable, because if I open it in a text editor... (yes, I tried that) it is present, so, it is being included.</p>
  
  <p>the first function was an attempt to walk through all the file resources in an attempt to locate the data.  It found types 2, 3, 14, 16 and 24., but not 10.  I have ruled out these other types as being the above mentioned resources. (bitmap=2), (icon=3), (RT_ICON(3)+RT_ICON_GROUP(11)=14)  (version=16), (manifest=24).  User defined should be type 10, and it didn't find it.</p>
  
  <p>My Resources.rc file includes the following:</p>
  
  <pre><code>LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
  IDR_textfile1      textfile       ".\\Data\\World.txt"
  </code></pre>
  
  <p>This defines the file to be loaded,  (again, I know this works, I can see the text of the code IN the executable.)</p>
  
  <p>My resources.h file defines the following:</p>
  
  <pre><code>#define IDR_textfile1                           102
  </code></pre>
  
  <p>So, it is being defined, included, built, and all the other resources work, and yet, FindResourceExA returns NULL on this.  All the include files are lined up, (i'd get warnings and errors if it was not.)</p>
  
  <p>So, the question is, am I calling FindResourceExA correctly?  it is defined as:</p>
  
  <pre><code>WINBASEAPI HRSRC WINAPI FindResourceExA(HINSTANCE,LPCSTR,LPCSTR,WORD);
  </code></pre>
  
  <p>well, I have tried for HINSTANCE, null, hInstance passed to be my Windows in WinMain, even GetModuleHandleA's results, no dice.</p>
  
  <p>For LPCSTR, which is the resource ID, I have tried what you see, MAKEINTRESOURCE(IDR_textfile1), and I have tried hard coding the ID number as well, in this case, 102.    No dice.
  For the type, I have tired other variations, the correct value according to Microsoft should be 10.   That's why I crated the EnumResNameProc, trying to see what other IDs exist, from 0 to 500, and all I got back was the ones listed above, on the off chance something was defined funny.    No Dice.</p>
  
  <p>I have tried both FindResourceExA FindResourceA  (with and without the 'Ex')
  No Dice.</p>
  
  <p>I know it is there, I have learned more then I care to about this function, but it won't find it, and I am at a loss at what else to try.</p>
  
  <p>As for development environment, I am using MinGW+Eclipse+CDT, and using winres from the GCC tools to build the resource object file.   I have looked for bugs in winres to see if it is doing something funny on binary types.  (that's what undefined are considered, even though I am loading a text file.)  oh, I also tried re-saving the file as ANSI, UTF-8, and UNICODE in case the binary format of the text mattered.  </p>
  
  <p>I am at a loss, I don't know what else to try.  I know the data is there, I just don't why it won't access it.  The Windows API call can't either see the data, or the data is encoded in a screwey way and so it doesn't access it.</p>
  
  <p>What else can I try?</p>
  
  <pre><code>BOOL CALLBACK EnumResNameProc (
    HMODULE hModule,
    LPCTSTR lpszType,
    LPTSTR lpszName,
    LONG_PTR lParam)
  {
      std::cerr &lt;&lt; "WTF INFO BEGIN here! \n";
      // std::string info = lpszName;
      int a = lParam;
      std::cerr  &lt;&lt; "We found something: " &lt;&lt; a &lt;&lt; std::endl;
      MessageBoxA ( NULL, lpszName, (LPCSTR) "Found: ", MB_OK);
      std::cerr &lt;&lt; "WTF INFO END here! \n";
      return true;
  } 
  
  void LoadFileInResource( HINSTANCE hInstance,
                           int name,
                           int type,
                           DWORD size,
                           const char* data)
  {
      //  HMODULE handle = GetModuleHandleA(NULL);
  
      for (int a = 0;a&lt;500;a++) {
      EnumResourceNamesA(hInstance, MAKEINTRESOURCE(a),
                        (ENUMRESNAMEPROCA) &amp; EnumResNameProc, (LONG_PTR) a);
     }
  
     HRSRC rc = FindResourceExA(hInstance,
                                 MAKEINTRESOURCE(IDR_textfile1),
                                 MAKEINTRESOURCE(10),
                                 MAKELANGID(LANG_NEUTRAL,
                                 SUBLANG_NEUTRAL));
     if (rc == NULL) {
         DWORD fup = GetLastError();
         MessageBoxA ( NULL, (LPCSTR) "Crap not loaded.", (LPCSTR) "Error", MB_OK);
         std::cerr &lt;&lt; "Crap not loaded, ERR: " &lt;&lt; fup &lt;&lt; std::endl;
     }
  
     // MessageBoxA ( NULL, (LPCSTR) " Test ", (LPCSTR) "Found: ", MB_OK);
     HGLOBAL rcData = LoadResource(hInstance, rc);
     // data = static_cast&lt;const char*&gt;(LockResource(rcData));
     data = (const char*) LockResource(rcData);
     size = SizeofResource(hInstance, rc);
     std::cout &lt;&lt; "Res size = " &lt;&lt; (long) size &lt;&lt; std::endl;
     std::cout &lt;&lt; "data =" &lt;&lt; data &lt;&lt; :: std::endl;
     //    wsprintf(szMsg,"Values loaded : %d, %d, %d\nSize = %d",
     //    pmem-&gt;Value1,pmem-&gt;Value2,pmem-&gt;Value3);
     //   MessageBox(hWnd, szMsg,lpszAppName,MB_OK);
  }
  </code></pre>