Can 3dgs read from and write to %appdata%?

Posted By: Germanunkol

Can 3dgs read from and write to %appdata%? - 07/23/10 18:06

We're having the Problem that our game, once installed, won't run on win7 and Vista, seemingly because of administrative rights. We need to write and modify files in the folders. The manual entry on "save_dir" says to change the dir on windows vista.
Now we want to change the dir where everything is saved to the application data, since that's what it's for. Can 3dgs somehow access the %appdata% variable at runtime without any plugins?
Posted By: DJBMASTER

Re: Can 3dgs read from and write to %appdata%? - 07/23/10 18:12

The win32 function 'SHGetFolderPath" is what you want. You can pass in environment variables like APPDATA, PROGRAM_FILES, SYSTEM and it will return the path on the current system...

http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx
Posted By: Germanunkol

Re: Can 3dgs read from and write to %appdata%? - 07/23/10 18:37

Uh, yes. Exactly. Thanks...
How do I access that function in LiteC though? This gives me a syntax error:
HRESULT WINAPI SHGetFolderPath(HWND hwndOwner, int nFolder,HANDLE hToken,DWORD dwFlags,LPTSTR pszPath);
#define PRAGMA_API SHGetFolderPath;Shell32.dll!SHGetFolderPath
Posted By: Joey

Re: Can 3dgs read from and write to %appdata%? - 07/23/10 18:39

just an assumption: you have to specify either SHGetFolderPathA or SHGetFolderPathW
Posted By: DJBMASTER

Re: Can 3dgs read from and write to %appdata%? - 07/23/10 19:46

Code:
#include <acknex.h>
#include <default.c>
#include <windows.h>

HRESULT WINAPI SHGetFolderPath(HWND hwndOwner, int nFolder,HANDLE hToken,DWORD dwFlags,char* pszPath);
#define PRAGMA_API SHGetFolderPath;Shell32.dll!SHGetFolderPathA

const int APPDATA = 0x001A;
char buffer[260];

void main()
{
	
	SHGetFolderPath(NULL,APPDATA,0,NULL,buffer);
	error(buffer);
}


Posted By: Germanunkol

Re: Can 3dgs read from and write to %appdata%? - 07/23/10 20:29

Perfect. Thank you very much.
I didn't convert LPTSTR into a char* pointer... and SHGetFolderPathA was the other Rroblem. So 0x001A is the value of CSIDL_APPDATA? interesting...
Posted By: DJBMASTER

Re: Can 3dgs read from and write to %appdata%? - 07/23/10 21:09

Yeh sorry I should have mentioned you have 2 signatures for ansi (SHGetFolderPathA) and unicode (SHGetFolderPathW).

I use this page to find all the CSIDL values...

http://www.pinvoke.net/default.aspx/shell32.shgetfolderpath
© 2024 lite-C Forums