2 registered members (dr_panther, 7th_zorro),
1,203
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
User
|
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:
#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:
///////////////////////////////
#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: Emre]
#477257
06/07/19 01:38
06/07/19 01:38
|
Joined: May 2005
Posts: 868 Chicago, IL
Dooley
OP
User
|
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 @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
User
|
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.
|
|
|
|