Write txt in program files, not allowed in vista!

Posted By: Toon

Write txt in program files, not allowed in vista! - 11/02/09 22:12

Code:
var save_handle;

function save_settings()
{		
  save_handle = file_open_write("resolution.txt");
	
  file_var_write(save_handle,resolution);

  file_close(save_handle);
}



We made a save system in our game based on code like this right up here. We really want to install the game in the program files folder but Vista seems to have a problem with reading and writing files like that in that folder.

It says "Empty pointer in"E1415, invalid pointer or handle in".

Anyone knows a solution to this?
Posted By: Lion_Ts

Re: Write txt in program files, not allowed in vista! - 11/03/09 23:15

Vista has the UAC rules, you should write your data to specific folders only (%USERPROFILE%\AppData\Local, for example), or you have to modify your installer to allow "program files" folder access for your application (this is the very bad way).
btw, under xp or win2k we have the specific places to store an application data too (like "Documents and Settings\All Users\Application Data", for example).
Refer to msdn, please; look for the SHGetKnownFolderPath (SHGetFolderPath).
Posted By: Toon

Re: Write txt in program files, not allowed in vista! - 11/06/09 14:51

Thanks for your reply.

Are prefixes like %USERPROFILE% possible in gamestudio path descriptions?
Posted By: Lion_Ts

Re: Write txt in program files, not allowed in vista! - 11/06/09 19:16

There is nothing to do with that shell variable (prefix) under GS. Actually, you can obtain the value of that variable, but there is more convenient way. Look at SHGetFolderPath. You can call it to obtain the right place to store your data.
Posted By: Ganderoleg

Re: Write txt in program files, not allowed in vista! - 11/06/09 20:12

Ups this is news to me- I have exactly the same save system as this one frown
My txt files are in the same folder as exe and I had no problem under Xp but haven't test it under Vista.

Is there same example in C-Script on how this can be fixed ( I don't really understand how to use information from suggested link (SHGetFolderPath))?
Posted By: testDummy

Re: Write txt in program files, not allowed in vista! - 11/06/09 21:40


Code:
var save_handle = 0;

function save_settings() {		
	save_handle = file_open_write("resolution.txt");
	if (save_handle == 0) { 
		error("Hello user.  A save system error has occurred.");
		error("To resolve this issue, you might try to 'revert' to a 'better' OS or modify user priviledges for folder n.");
		error("We recommend that you send a report to Microsoft and then go try to make better use of your time.");
		error("Why are you still here?");
		return;
	}
	file_var_write(save_handle,resolution);
	file_close(save_handle);
}



Quoting Ganderoleg.
Quote:
Is there same example in C-Script on how this can be fixed...



Indeed, that wasn't it.


point @ idea fair & obvious = check return value
Posted By: Ganderoleg

Re: Write txt in program files, not allowed in vista! - 11/06/09 22:21

smile smile O.k. but I'm not sure about the point thing: return value? ...of what? I have txt files already present in the exe folder. Is this a problem with all Vista versions?
Posted By: Lion_Ts

Re: Write txt in program files, not allowed in vista! - 11/07/09 00:12

This is not a problem. This is the feature laugh
If you have the GS7 then you can call the SHGetFolderPath function (contained in the shell32.dll version 5.0 or later) using liteC language, save returned path string, concatenate it with you file name and do what you need. If you're using older GS version then you can build "wrapper" dll for some needed OS/shell interfaces to call the wrapper from C-script. That's all...
Posted By: Ganderoleg

Re: Write txt in program files, not allowed in vista! - 11/07/09 00:45

Thanx for reply. Can way to do this be found in the manual? I have no idea on how to make wrapper dll frown
I am using a small proportion of Lite-C with C-Script in my game but only for PP Effects. They can't share variables as I remember.

Can some free dll of this kind be found on the forum? I can't believe that no one needs this feature.
Posted By: Toon

Re: Write txt in program files, not allowed in vista! - 11/26/09 17:13

How to create such a dll? I tryed the regular savesystem (gamestudio) as well but also without results.

Is there no other way to check for the users paths in c-script? Or perhaps a way to share variables between the two languages?

confused Can anyone tell me how to save files from an .exe that is started in the program files folder on a Vista with c-script...
Posted By: Toon

Re: Write txt in program files, not allowed in vista! - 12/01/09 17:48

Is there any way for a c-script application (excisting dll perhaps) to check where the user file paths are like My Documents etc. ?

Anyone?
Posted By: Toon

Re: Write txt in program files, not allowed in vista! - 12/08/09 15:36

Is there a way for a c-script application to interprete a command line parameter as a string like this;

-parname "teststring"

If so, how can I use the string in the script?
© 2024 lite-C Forums