Adding and using resources files on Visual Studio - c++

I have to use text files files on my project on Visual Studio, and instead of working with file streams I'd like to add them directly to the build.
I have added them to the solution explorer and edited their properties changing the Item Type to Resource.
Now I want to know how may I access their content, say, put their text into a string. (I'm using C++)
PS: Is there a good tutorial about using resource files? Couldn't find any recent tutorial for visual studio.

To retrieve a user-defined resource from within your executable see the FindResource, LoadResource and LockResource APIs.

Related

How do i put raw binary data from file into Windows resource file and extract in into void* in my program? [duplicate]

So I have a Visual Studio 2008 project which has a large amount of binary data that it is currently referencing. I would like to package the binary data much like you can do with C# by adding it as a "resource" and compiling it as a DLL.
Lets say all my data has an extension of ".data" and is currently being read from the visual studio project.
Is there a way that you can compile or link the data into the .dll which it is calling?
I've looked at some of the google link for this and so far I haven't come up with anything - the only possible solution I've come up with is to use something like ResGen to create a .resources file and then link it using AssemblyLinker with /Embed or /Link flags. I dont think it'd work properly though because I dont have text files to create the .resources files, but rather binary files themselves.
Any advice?
Right click the resource script (.rc file)
Choose Import
http://msdn.microsoft.com/en-us/library/saced6x2.aspx
You can embed any "custom" file you want, as well as things like .bmps and stuff VisualStudio "knows" how to edit. Then you can access them with your framework's resource functions like FindResource LoadResource etc...
If you don't have a resource script.
Click Project
Add New Item
Resource Script
http://msdn.microsoft.com/en-us/library/sxdy04be(v=VS.71).aspx
You can embed the binary data as a C language array - no resources involved at all.
An old classic trick.
see for example XD

app.config visual studio creation

A simple question, where I have perhaps just overlooked the obvious.
I am trying to use ApplicationSettings in C++ (.NET) using Visual Studio 2010 Express (I also use 2008 pro)
However I can get nowhere with this - if I try to use the form designer to add a setting i get "No settings file exists in project. Add a settings file and try again". How do I add a setting file (app.config)? There is no option in any of the "add" sections. I have tried adding a file manually both from within VS (create a new file and save) and from Explorer.
Before I crack and just write some code to read an XML config file - please can someone explain the correct way to setup and use app.config - just, for example, to save the location and size of the main form.
Is this a managed C++ project?
A settings file is based on .Net's ApplicationSettingsBase and ConfigurationManager classes, so unless you're using .Net you won't be able to use them easily.
EDIT: I've just created a managed C++ project, and you're right, there is no option to add a settings file.
In a C# project this produces a static class derived from ApplicationSettingsBase, which Visual Studio updates automatically from a GUI based configuration screen. I can only assume that there is no support for auto generation of a managed C++ class instead. Sorry.

C++ parsing a text file that is located online

Information about what I want to do:
-read in a few integer variables from a text file that will be located on a dropbox public folder.
-the variables will be used to trigger some if statements thus controlling my application remotely if I need to have it do something ( I would just save the variable I need to that text file and my program with would read from it every 5 seconds would see it and perform the required actions).
-this is a console application which is being built and compiled in visual studio 2010 on windows 7. The software will also be running on a win7 computer.
I need help with:
I already have read on using a library called libcurl. The problem is that I do not know how to link this library with my project in vs2010. Detailed instructions on how to do this on vs 2010 would be very helpful.
OR
if you can think of a better and easier way to accomplish what I need done, offer some advice and direction
It sounds like you're a novice, is that correct? If not then apologies for stating the obvious.
To use your compiled DLL in your application you need to 'add a reference' to it. You can do this by adding what is called a binary reference, where you simply tell visual studio where to find the dll. Or you can add a project reference if the project which is producing the dll is within the same solution. The best approach is to use something called nuget. It's a visual studio extension which automates the adding of binary references available from a public repository.
I have just done a search for libcurl on nuget.org and drew a blank. As I am unfamiliar with this library you may have better luck finding a nuget package as you will be a le to search using better terms that I did (curl and libcurl)
Whatever approach you take, just right-click on the project in which you want to use libcurl within the solution explorer and you should find an add reference option in the menu.

Read multiple files

I'm new to c++ and am trying to alter the console app code posted below to read multiple files, ideally using a wildcard extension. Can some please give me some pointers..?
http://msdn.microsoft.com/en-us/library/ms916815#odc_wssusageeventlogging_examiningtheusagelogfileformat
-----------Edit-------
What I need is how to change the code above instead of pointing it to a specific [filename.log] point it to a directory name and let it process all the log files in that directory.
--------------Tools-----
Win32 Console Application project in Visual Studio 2010 in C++
[To be run on win 32 bit platform]
Using Win32 APIs you can list the files in a directory by following this example. From there it should be relatively trivial for you to incorporate that code into your application to allow you to process multiple files as requested.
Specifically the FindFirstFile API allows for wildcard when search for files.
If you're willing to use the boost library check out
this post. If you're using something like C++/CLI then there is support in .NET for this as well (I'm assuming for now you're not using C++/CLI). If you specify the tools at your disposal maybe you can get a more directed answer.

Using Visual studio .ncb file for reflection

I am developing visual game level editor in C++.
For this I want reflection(RTTI) mechanism to know class attributes at runtime.
I am currently using PDB files for this.But using PDB I couldn't retrieve actual code line for extra information in commented format which is given for that attribute.
Visual studio uses NCB files for intelligence.
So will it be better idea to use NCB instead PDB?
If yes,How to retrieve information from NCB files?
Is there any SDK like DIA SDK?
The NCB file format isn't publicly documented and changes with every version of Visual Studio. With the upcoming VS2010 (due out in about a week and a half), it's going away entirely in favor of a new SQL-based format that should be much easier to work with. Microsoft is also implementing an API for integrating with the Intellisense data from the parser.
I really wouldn't rely on the .ncb files for reflection. Those files are meant for intellisense, and only intellisense. They could change without warning, not be up to date, or what have you...
You could do some macro hackery to get the reflection you seek (something like push your variables/methods into some container, and declare it simultaneously)... or use a framework like Qt (which is what I've been using for my level editor).