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:
IDR_APPLICATION1 Application "embed.exe"
And the .h includes:
#define IDR_APPLICATION1 101
The problem is the following function fails
hrsrc = FindResource(NULL, (LPCWSTR)IDR_APPLICATION1, RT_RCDATA);
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.
Thanks in advance.
EDIT:
I tried each of these lines individually but none of them worked and each time GetLastError() returned 1813.
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
Here are 3 possible issues:
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.
2 - The resource named "embed.exe" was automaticly added to the "Sources" filter/folder, maybe it should be in the "Resources" filter/folder?
3 - When I right click "embed.exe" from Solution Explorer, the properties have not been changed, and here they are:
Excluded from build: (empty)
Content: (empty)
Item type: Does not participate in build