title: How to extract a resource file from a .dll - Visual Studio 2013
body: <p>I'm using visual studio 2013 and i'm making a dll file that extracts an executable file embed in it to a directory. First I imported the .exe file as a resource and changed the type to "Application". I can see in solution explorer that embed.exe is located under "Source Files". 2 new files have been created automaticly: Project.rc and resource.h. The .rc file includes this line:</p>
  
  <pre><code>IDR_APPLICATION1        Application             "embed.exe"
  </code></pre>
  
  <p>And the .h includes:</p>
  
  <pre><code>#define IDR_APPLICATION1                101
  </code></pre>
  
  <p>The problem is the following function fails</p>
  
  <pre><code>hrsrc = FindResource(NULL, (LPCWSTR)IDR_APPLICATION1, RT_RCDATA);
  </code></pre>
  
  <p>And GetLastError() returns 1813 which means, according to previous threads I visited, that the type (RT_RCDATA) is invalid. I've seen many threads but nothing helpful. I also tried to list resources but I ended up with a too complicated code where I couldn't find the problem.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I tried each of these lines individually but none of them worked and each time GetLastError() returned 1813.</p>
  
  <pre><code>hrsrc = FindResource(NULL, (LPCWSTR)IDR_APPLICATION1, (LPCWSTR)L"Application");
  hrsrc = FindResource(NULL, MAKEINTRESOURCE(IDR_APPLICATION1), _T("Application"));
  hrsrc = FindResource(NULL, (LPCWSTR)IDR_APPLICATION1, _T("Application")); //mix of both
  </code></pre>
  
  <p>Here are 3 possible issues:  </p>
  
  <p>1 - The first parameter (argument) of FindResource() is the instance of the application, but I'm coding a DLL file, so I set it to NULL. The .exe file running the application has no resource of type "Application", but the .dll file does.  </p>
  
  <p>2 - The resource named "embed.exe" was automaticly added to the "Sources" filter/folder, maybe it should be in the "Resources" filter/folder?</p>
  
  <p>3 - When I right click "embed.exe" from Solution Explorer, the properties have not been changed, and here they are:</p>
  
  <p>Excluded from build: <em>(empty)</em><br>
  Content: <em>(empty)</em><br>
  Item type: Does not participate in build</p>