I have encountered a problem when deploying a game I made in C++. I will try and be as specific as possible.I did research this thoroughly on Google and I also asked a former programming teacher and he recommended I post to this site. I created a game in C++ and inside the source folder I had added 3 text files named: "SavedGame1.txt" "SavedGame2.txt" and "SavedGame3.txt". I built a save function that when triggered, it writes the information such as player name, class, hitpoints, mana, etc to the text file so it can be read back later in my continue function. When I run it in Visual Studio (I am using Visual Studio 2010 by the way), it will write to the text file like desired and read back from the text file. After I deploy the game, it will read from the text files if they have data in them before I deploy the game, but the problem is after deployment, it will not write to the text files. This makes my save game function worthless. I found a way around this by creating a directory upon running my deployed game and then creating the save game text files in the directory, but then I face the issue of having to run the game in Admin mode or else it will not write to the text files. Can anyone tell me what I can do to get it to write to the text files so that the user does not have to be in Admin mode to use the save function.
You can do the following:-
1) When you deploy your text files, create a folder under the ApplicationData folder for that specific user.
2) Deploy your text files to this folder
3) Read and write to the files in the above folder when required
The ApplicationData folder stores the application specific data of the user and is always accessible (even for non admin users)
In C++ you get the ApplicationData folder like this (pointing you to another answer on SO: ApplicationData
Related
I have a c++ app where I use LoadString to read string entries from an embedded .rc file. Is there a way to write append/update string entries like a WriteString?
Looking for a way to write to a resource file within a c++ app
No, there is no such function. Programs are usually installed in places where the user running them does not have permission to change files - so the ability to change the actual executable is not something that's been requested very often.
I suggest that you store the information somewhere in the %AppData% directory or registry instead.
Basically I have an image I'm trying to use as a splash screen. I set up the splash screen and even told it the location(":/Nuclear_Vortex_100_About.jpg") but when I run the program, all I see is a general window background "window"(no close box or any of the decoration, just a widget for lack of a better word) and no image on it.
I added the file (along with a bunch of other images I want to later load and use in the app) and they show up in the "Other Files" folder - ok so I figured since they're in the project, that they would be seen as resources if not source or headers. Do I need to add a special section to the PRO file or something in order to use the file? I'm about to just hard code an absolute path just to get it to work but I want a system independent way to get this done. I'm going to be paid for this project and I don't have much experience with the resource system in QT but it wasn't hard in Visual Studio and other C++ environments. As I see the splash screen show up, I know that part is working. The only thing I don't know for sure is that the file is not being found - that is I have not verified by using QFile and checking if it exists - I'll be doing that after I post this as it'll take some time to get a response or 2.
I have been searching for over a day and a half all over google and haven't found anything telling me what I'm doing wrong.
Thank you!
create resource file (.qrc) and add picture in it. It'll appear in resources section of your project. Then you can use it freely in your program.
I am working on a image processing project. I am not familiar with html. Here is what I think.
My C++ application is able to read an image and write the image to file after processing. The procedural is that user can click mouse in a fixed region of my web, and the position data could be passed as parameter to my application, and then my C++ application will use the position data to process the image and output image to file, finally my web display the image.
So is that possible to implement this?
I'm afraid it's not possible only with HTML.
It should be possible with any server-side scripts written in PHP (for example). Anyway, you can make you program to watch folder uploaded and processed images save into another folder. You will need PHP or something like this though.
I created application that store some data to XML file. The issues is with the path of the XML saving. Am using TinyXML to save the data in vc++.
When I deploy this application, it installs in "C:\Program files(x86)\applicationname " and when I run the application the XML file is saving in
"C:\Users\UserName\AppData\Local\VirtualStore\Program Files (x86)\ApplicationName ".
I have made this application to work on system startup. So when I restart this application,
the xml file is stored in different path "C:\Users\UserName\AppData\Local\VirtualStore\windows\sysWOW64"
I want my XML to be stored in the path where I installed or should be stored in appdata, application name
What should I do to store XML file in one places where application is installed?
doc.SaveFile( "test.xml" ); // xml saving code in tinyxml library
Firstly, this has nothing to do with C++, as the C++ code is probably working. Same with XML and tinyxml and even visual-c++.
It seems that windows redirects those write accesses to a user-specific "VirtualStore\Program Files", but I'll leave it to you to research the actual semantics of that. On startup, when there is no user, this path obviously differs, since the former user is not logged in.
Now, in order to get a fixed path, you can use the function GetModuleFileName() to find out the location of your executable and use that path to locate Smartmeter.xml. However, the problem you are facing now is that programs installed under "Program Files" don't magically gain write access rights to their install directory. This is to protect one user from messing with data of another user.
I think that what you are doing is writing a program that runs in the background, which would be called a "service" under MS Windows. What is still unclear is what you want to achieve with this file and also what you are planning to do overall, and these are things that decide the future steps. In any case, take a look at the possibilities that services provide, maybe there is something that fits your needs.
I'm developing a game for mi Advance Algorithm class, but I'm having a problem with the read and save. I want to save the "fields" on a .txt file but on a specific folder in my solution. I want to create 1 file per field, and I want to read all the .txt files on that specific folder when I load the solution. The user must not send any address for saving or reading, that must be done by default by the program. I'm actually using this :
FILE* arch =fopen("Tableros.tbl","wt");
if(arch==NULL)return;
Same thing for reading. But I can only read one file, and I want to detect or read all .txt on that specific folder. Any ideas or functions that can help?
I'm using visual studio 2010 c++.
Use GetCurrentDirectory() function to retrieve current process directory. Then use search in the directory (FindFirstFile(), FindNextFile() and other) to detect and read all files in cycle.