Answered by:
Include .js files (and others) in build

Question
-
Im pretty new to this but basically, I want to include a few .js files in the build of a win32 application.
I want to be able to read in its contents and output it in the header of a html file (for portability).
Reason I need to have the .js file included instead of just as an external is because I'd like the end solution to be a single .exe file.
Thanks in advance for any help
- Edited by alendamadzic Friday, November 11, 2011 12:43 PM
Friday, November 11, 2011 12:42 PM
Answers
-
alendamadzic wrote:
Im pretty new to this but basically, I want to include a few .js files in the build of a win32 application.
Add them as resources. Project | Add Resource | Import, browse for your file. When prompted, enter resource type (any string will do, though RCDATA is often used by convention).
At run time, use FindResource, LoadResource and LockResource to obtain the pointer to resource data, SizeofResource to get its size.
Igor Tandetnik
- Proposed as answer by Helen Zhao Wednesday, November 16, 2011 1:44 AM
- Marked as answer by Helen Zhao Wednesday, November 16, 2011 4:01 AM
Friday, November 11, 2011 1:03 PM -
Hi,
Welcome to the MSDN Forum.
I agree with Igor, we can add .js files as resources.
1->Click View and select Resource View. Then the resource view will be displayed.
2->Right click the .rc file of your project and select "Add Resource… " . Then we will see several types of resources we can choose in “Add Resource” window.
3->Select "HTML" in "Add Resource" window and import the .js files.
Then, the .js files will be HTML resources of the project.
Or, we can treat .js files as regular files. That is, we use file management functions, such as OpenFile and ReadFile, to do the reading.
I hope the reply is helpful to you.
Best regards,
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- Edited by Helen Zhao Monday, November 14, 2011 8:44 AM
- Marked as answer by Helen Zhao Wednesday, November 16, 2011 4:01 AM
Monday, November 14, 2011 8:42 AM
All replies
-
alendamadzic wrote:
Im pretty new to this but basically, I want to include a few .js files in the build of a win32 application.
Add them as resources. Project | Add Resource | Import, browse for your file. When prompted, enter resource type (any string will do, though RCDATA is often used by convention).
At run time, use FindResource, LoadResource and LockResource to obtain the pointer to resource data, SizeofResource to get its size.
Igor Tandetnik
- Proposed as answer by Helen Zhao Wednesday, November 16, 2011 1:44 AM
- Marked as answer by Helen Zhao Wednesday, November 16, 2011 4:01 AM
Friday, November 11, 2011 1:03 PM -
Would this be the same for any kind of resource, such as images, css files etc.
How would this be used in an example..
Thanks for all the help
Friday, November 11, 2011 2:46 PM -
Hi,
Welcome to the MSDN Forum.
I agree with Igor, we can add .js files as resources.
1->Click View and select Resource View. Then the resource view will be displayed.
2->Right click the .rc file of your project and select "Add Resource… " . Then we will see several types of resources we can choose in “Add Resource” window.
3->Select "HTML" in "Add Resource" window and import the .js files.
Then, the .js files will be HTML resources of the project.
Or, we can treat .js files as regular files. That is, we use file management functions, such as OpenFile and ReadFile, to do the reading.
I hope the reply is helpful to you.
Best regards,
Helen Zhao [MSFT]
MSDN Community Support | Feedback to us
- Edited by Helen Zhao Monday, November 14, 2011 8:44 AM
- Marked as answer by Helen Zhao Wednesday, November 16, 2011 4:01 AM
Monday, November 14, 2011 8:42 AM -
Brilliant. All fixed now, used Find, Load and LockResource to get .js file.
Thanks for all the help.
Monday, November 14, 2011 10:39 AM