Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Nymphodora, AndrewAMD, TipmyPip, Quad, Imhotep), 847 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 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: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
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: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
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: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
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: 619
Turkey, Izmir
Emre Offline
User
Emre  Offline
User

Joined: Jul 2007
Posts: 619
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: 868
Chicago, IL
Dooley Offline OP
User
Dooley  Offline OP
User

Joined: May 2005
Posts: 868
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