Gamestudio Links
Zorro Links
Newest Posts
FXCM: "Can't connect to price server"
by jcl. 06/19/19 15:47
Data Execution Prevention Strikes Again
by Dooley. 06/19/19 15:38
assert
by jcl. 06/19/19 14:59
Bring the old grin back!
by Michael_Schwarz. 06/19/19 07:56
Help with calculation
by Qw3rty. 06/18/19 08:01
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
13 registered members (AndrewAMD, Kaga, JeyKey II, Dooley, Grat, kvm, alibaba, Ayumi, MatPed, 1 invisible), 632 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Qw3rty, Dal, Carson, giantj, dh85
18236 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Creating a Directory [Re: WretchedSid] #476557
03/09/19 21:34
03/09/19 21:34
Joined: Jul 2007
Posts: 509
Turkey, izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 509
Turkey, izmir
Yes. And it's not big deal. i already gave the sample. Here is new one:

Dll:

Code:
#include <wchar.h>
#include <KnownFolders.h>
#include <shlobj.h>
#include <comdef.h> 

wchar_t* path = new wchar_t[256];
DLLFUNC void  SHGetKnownFolderliteC(int id, char* str)
{
	
	if (id == 1)
	{
		SHGetKnownFolderPath(FOLDERID_LocalAppData, 0, NULL, &path);
	}
	else if (id == 2)
	{
		SHGetKnownFolderPath(FOLDERID_PublicDesktop, 0, NULL, &path);
	}
	else if (id == 3)
	{
		SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, &path);
	}
	else if (id == 4)
	{
		SHGetKnownFolderPath(FOLDERID_RoamingAppData, 0, NULL, &path);
	}
	else 
	{
		SHGetKnownFolderPath(FOLDERID_Fonts, 0, NULL, &path);
	}
	

	if (path != NULL)
	{
		_bstr_t b(path);	strcpy_s((char*)str, 256, (char*)b);
	}
	


}



Lite-c:

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

//needed windows.h
char* savedir_str="";
void SHGetKnownFolderliteC(int id,char* str);
#define FOLDER_LocalAppData 1
#define FOLDER_PublicDesktop 2
#define FOLDER_ProgramData 3
#define FOLDER_RoamingAppData 4 


void main()
{
	SHGetKnownFolderliteC(FOLDER_LocalAppData,savedir_str);
	printf(savedir_str);
	sys_exit("");
}



ask someone skilled if there is something wrong with the sample. if it's okay, then use it.

i don't know what else you want.

Re: Creating a Directory [Re: WretchedSid] #477256
06/07/19 01:35
06/07/19 01:35
Joined: May 2005
Posts: 646
Chicago, IL
Dooley Online OP
User
Dooley  Online OP
User

Joined: May 2005
Posts: 646
Chicago, IL
Follow up question ...
I am seeing that if I run the game on one account, it will create the folder as instructed, now problems.

However, if I log onto the same computer under a different user name, and run the game, it will not have access to the same folder, and it will get an "invalid pointer" error when trying to start a new game (and thereby write files into that folder).

Is there a way to create the folder to make it public, rather than private to the account that made it?




Re: Creating a Directory [Re: Emre] #477257
06/07/19 01:38
06/07/19 01:38
Joined: May 2005
Posts: 646
Chicago, IL
Dooley Online OP
User
Dooley  Online OP
User

Joined: May 2005
Posts: 646
Chicago, IL
UPDATE:
Yes, it seems to work perfectly! You guys are great, you answered my questions before they even occurred to me. Thanks for being patient laugh

@Emre,
I just saw your sample, and I think it might solve my new problem.

By placing the file into "FOLDER_LocalAppData" instead of "FOLDER_ProgramData" I'm thinking that would create a new file location for each user, and there would be no problems for users with different accounts.

Thanks again!


Last edited by Dooley; 06/07/19 02:41.



Re: Creating a Directory [Re: Dooley] #477269
06/08/19 19:15
06/08/19 19:15
Joined: Jul 2007
Posts: 509
Turkey, izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 509
Turkey, izmir
You are welcome. Yet you may still face with a problem. Some people use unicode characters in their username. I suggest you to take a look at this post.

Though that post about SHGetFolderPath, maybe you may encounter the same problem with SHGetKnownFolderPath. I am not sure. Just an advice.

Re: Creating a Directory [Re: Emre] #477270
06/08/19 22:21
06/08/19 22:21
Joined: May 2005
Posts: 646
Chicago, IL
Dooley Online OP
User
Dooley  Online OP
User

Joined: May 2005
Posts: 646
Chicago, IL
Okay, I will have to put in some kind of backup plan for that situation I guess.




Page 2 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1