Which directory should I choose to store data files created in my application?
Which directory should I choose to store data files created in my application?
If my application creates data files, which directory to store these data files is the most appropriate. I mean those directories, that are read by "GetUserDirectory" command. Is it "GetUserDirectory(#PB_Directory_Documents)". Or - may be - is it not the best to create own directory to store data files, like "[drive]:\FilesOfMyProgram"? How do you, my colleagues, approach this issue.
Re: Which directory should I choose to store data files created in my application?
Code: Select all
GetUserDirectory(#PB_Directory_ProgramData)
Re: Which directory should I choose to store data files created in my application?
viewtopic.php?p=596867#p596867
You need to prompt the user to specify a directory for the data and save this path in the settings. The default is "My Documents". Another way the user will be unhappy with the fact that you create all sorts of garbage in his root folder.
Personally, I have two folders for documents, one folder is where the system litters (My Documents), the other is where I create my content.
You need to prompt the user to specify a directory for the data and save this path in the settings. The default is "My Documents". Another way the user will be unhappy with the fact that you create all sorts of garbage in his root folder.
Personally, I have two folders for documents, one folder is where the system litters (My Documents), the other is where I create my content.
Re: Which directory should I choose to store data files created in my application?
Depends if your app is released as portable or not. Mine is, so all settings are stored in a sub-folder of where the exe is. This means my users can copy my app's folder to any PC and run it immediately without installation or setup, with all data ready to go.
Re: Which directory should I choose to store data files created in my application?
Usually my apps are 'portable' (meaning they need NO installation but can be copied easily). Locations of folders are usually stored in preference-files (.ini) in the folder of the executable. When there is 'general' data, I use GetPathPart(ProgramFilename())+[subfolder] to define a subfolder of the executable.
Very rarely I use the registry to save data, but that is e.g. window-size and location, etc.
Very rarely I use the registry to save data, but that is e.g. window-size and location, etc.
Re: Which directory should I choose to store data files created in my application?
Dear Colleagues! All your answers are spot on.
Fips proposal:
gives me the result:
C:\Users\Jan2004\AppData\Roaming\
I submitted a query to Google "What is Roaming folder for?" I got the answer: "The Roaming folder is used to store data that will be synced across multiple Windows systems. This is often used for storing settings like bookmarks, saved passwords, and so on".
AZJO proposal. I understand that this is a directory that is selected with the following command:
I have the following result:
c:\Users\Jan2004\Documents\
I noticed that in this directory there are subdirectories of the programs I have installed: Audacity, Google Web Designer, MuseScore4, NetBeansProjects, Wondershare DemoCreator.
BarryG and KosterNET propose release app as portable, then "all settings are stored in a sub-folder of where the exe is".
Of course, in this proposal, storing the created files in the subdirectory of the application resides is understandable. Just a little point from my experience: if you're going to be copying all your files to your computer's hard drive, which some people do and I'm one of them, don't put them in the "Program Files (X86)" or "Program Files" directory, because Windows may not want to save user-created files to their subdirectories.
Conclusions (my procedures - what I will be doing):
1.
Files with program settings (XML) and small files (TXT flags) created in response to user actions, which in my opinion are confidential, will be stored in the subdirectory: C:\Users\Jan2004\AppData\Roaming\
I bet - 99 percent of users don't know that such a directory exists.
2.
Files created during the program operation, such as: SQLITE, PDF, RTF, etc will be placed in the subdirectory:
c:\Users\Jan2004\Documents\
Thanks to my colleagues for participating in the post.
Fips proposal:
Code: Select all
Result$ = GetUserDirectory(#PB_Directory_ProgramData)
Debug Result$
C:\Users\Jan2004\AppData\Roaming\
I submitted a query to Google "What is Roaming folder for?" I got the answer: "The Roaming folder is used to store data that will be synced across multiple Windows systems. This is often used for storing settings like bookmarks, saved passwords, and so on".
AZJO proposal. I understand that this is a directory that is selected with the following command:
Code: Select all
Result$ = GetUserDirectory(#PB_Directory_Documents)
Debug Result$
c:\Users\Jan2004\Documents\
I noticed that in this directory there are subdirectories of the programs I have installed: Audacity, Google Web Designer, MuseScore4, NetBeansProjects, Wondershare DemoCreator.
BarryG and KosterNET propose release app as portable, then "all settings are stored in a sub-folder of where the exe is".
Of course, in this proposal, storing the created files in the subdirectory of the application resides is understandable. Just a little point from my experience: if you're going to be copying all your files to your computer's hard drive, which some people do and I'm one of them, don't put them in the "Program Files (X86)" or "Program Files" directory, because Windows may not want to save user-created files to their subdirectories.
Conclusions (my procedures - what I will be doing):
1.
Files with program settings (XML) and small files (TXT flags) created in response to user actions, which in my opinion are confidential, will be stored in the subdirectory: C:\Users\Jan2004\AppData\Roaming\
I bet - 99 percent of users don't know that such a directory exists.
2.
Files created during the program operation, such as: SQLITE, PDF, RTF, etc will be placed in the subdirectory:
c:\Users\Jan2004\Documents\
Thanks to my colleagues for participating in the post.
Re: Which directory should I choose to store data files created in my application?
I gave you more options than in your post.
1. If the ini file is located next to the program, then the config folder is the program folder and the program works as a portable one.
2. If the file is not found next to the executable file, then the program uses a special folder where application settings are stored.
3. If the file is a user's creation, then you can use the program directory in the first option, in the second option, if the program is not defined as portable, then use "My Documents".
I gave you the flexibility where the user can determine whether to make his program portable or make it built into the OS
Re: Which directory should I choose to store data files created in my application?
AZIZO. Of course you gave me more options. I should add that my preference stems from the fact that I will not be developing a portable program. Also, the possibility of choosing the directory, where the files will be stored, will be partially limited (I will inform the user about it in the help file).
Re: Which directory should I choose to store data files created in my application?
In one of the programs, I made a path capture from the clipboard. You check the path in the clipboard and if it exists, then if it is a file, then cut off the name leaving only the path to the folder and inform the user that the path is found in the clipboard (show which one), you want to use it ... If the user agrees, open the folder selection dialog setting this path as the default as a starting point, otherwise use "My Documents". Sometimes the folder selection dialog is very inconvenient, it opens an unnecessary path and the user has to move up each time, then open the path by clicking on the packs, this is tedious. Therefore, it is necessary to save the last selected folder and be able to grab the path from the clipboard, since sometimes it is easier to copy it from the address bar of an open folder and immediately apply it in your program, instead of changing the path leading to heavy searches for it in a small window.
Re: Which directory should I choose to store data files created in my application?
I agree with you 100 percent: it's like you're describing my struggles with some programs. I will use your valuable insights in the future.
Re: Which directory should I choose to store data files created in my application?
I'd immediately delete apps as soon as they store their data in #PB_Directory_Documents, because in fact, those are MY personal documents, and not the ones from any program.
Data belonging to programs have to go into #PB_Directory_ProgramData (+ subfolders), or in case they are running as a service, into #PB_Directory_AllUserData (+ subfolders)
For portable ones, those rules are not valid of course.
In case your program produces several hundreds of MB, I'd let the user decide where he wants to have it stored.
And that here:
would not result into the correct folder in my config here.
Don't forget that users also can move the Appdata folder to somewhere else.
Data belonging to programs have to go into #PB_Directory_ProgramData (+ subfolders), or in case they are running as a service, into #PB_Directory_AllUserData (+ subfolders)
For portable ones, those rules are not valid of course.
In case your program produces several hundreds of MB, I'd let the user decide where he wants to have it stored.
And that here:
Code: Select all
PathConfig$ = GetHomeDirectory() + "AppData\Roaming\MyProgName\"
Don't forget that users also can move the Appdata folder to somewhere else.
{Home}.:|:.{Dialog Design0R}.:|:.{Codes}.:|:.{History Viewer Online}.:|:.{Send a Beer}
Re: Which directory should I choose to store data files created in my application?
I use GetKnownFolderPath
search the forum for "knownfolders.pbi" for a simple procedure.
Jim
Code: Select all
If isportable
datafolder=programfolder+"Data\"
Else
datafolder=GetKnownFolderPath(?FOLDERID_LocalAppData)+"my_program_name\"
EndIf
userfolder=GetKnownFolderPath(?FOLDERID_Documents)
Jim
Re: Which directory should I choose to store data files created in my application?
HeXOR: your analysis is convincing, so I have revised point 2 of my conclusions.
2.
Files created during the program operation, such as: SQLITE, PDF, RTF, etc will be placed in the subdirectory of directory made by command:
Result$:
C:\ProgramData\
2.
Files created during the program operation, such as: SQLITE, PDF, RTF, etc will be placed in the subdirectory of directory made by command:
Code: Select all
Result$ = GetUserDirectory(#PB_Directory_AllUserData)
Debug Result$
C:\ProgramData\
Re: Which directory should I choose to store data files created in my application?
Jim, I decided to show your solution from the quoted post:
I have some code questions.
lines 4 to 123:
#FOLDERID_accountpictures = "{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}"
#FOLDERID_addnewprograms = "{de61d971-5ebc-4f02-a3a9-6c82895e5c04}"
and further.
What versions of Windows will this work on?
line 189:
hLib = OpenLibrary(#PB_Any, "shell32.dll")
Does this also work on Windows 64?
Code: Select all
EnableExplicit
#FOLDERID_accountpictures = "{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}"
#FOLDERID_addnewprograms = "{de61d971-5ebc-4f02-a3a9-6c82895e5c04}"
#FOLDERID_admintools = "{724ef170-a42d-4fef-9f26-b60e846fba4f}"
#FOLDERID_applicationshortcuts = "{a3918781-e5f2-4890-b3d9-a7e54332328c}"
#FOLDERID_appsfolder = "{1e87508d-89c2-42f0-8a7e-645a0f50ca58}"
#FOLDERID_appupdates = "{a305ce99-f527-492b-8b1a-7e76fa98d6e4}"
#FOLDERID_cameraroll = "{ab5fb87b-7ce2-4f83-915d-550846c9537b}"
#FOLDERID_cdburning = "{9e52ab10-f80d-49df-acb8-4330f5687855}"
#FOLDERID_changeremoveprograms = "{df7266ac-9274-4867-8d55-3bd661de872d}"
#FOLDERID_commonadmintools = "{d0384e7d-bac3-4797-8f14-cba229b392b5}"
#FOLDERID_commonoemlinks = "{c1bae2d0-10df-4334-bedd-7aa20b227a9d}"
#FOLDERID_commonprograms = "{0139d44e-6afe-49f2-8690-3dafcae6ffb8}"
#FOLDERID_commonstartmenu = "{a4115719-d62e-491d-aa7c-e74b8be3b067}"
#FOLDERID_commonstartup = "{82a5ea35-d9cd-47c5-9629-e15d2f714e6e}"
#FOLDERID_commontemplates = "{b94237e7-57ac-4347-9151-b08c6c32d1f7}"
#FOLDERID_computerfolder = "{0ac0837c-bbf8-452a-850d-79d08e667ca7}"
#FOLDERID_conflictfolder = "{4bfefb45-347d-4006-a5be-ac0cb0567192}"
#FOLDERID_connectionsfolder = "{6f0cd92b-2e97-45d1-88ff-b0d186b8dedd}"
#FOLDERID_contacts = "{56784854-c6cb-462b-8169-88e350acb882}"
#FOLDERID_controlpanelfolder = "{82a74aeb-aeb4-465c-a014-d097ee346d63}"
#FOLDERID_cookies = "{2b0f765d-c0e9-4171-908e-08a611b84ff6}"
#FOLDERID_desktop = "{b4bfcc3a-db2c-424c-b029-7fe99a87c641}"
#FOLDERID_devicemetadatastore = "{5ce4a5e9-e4eb-479d-b89f-130c02886155}"
#FOLDERID_documents = "{fdd39ad0-238f-46af-adb4-6c85480369c7}"
#FOLDERID_documentslibrary = "{7b0db17d-9cd2-4a93-9733-46cc89022e7c}"
#FOLDERID_downloads = "{374de290-123f-4565-9164-39c4925e467b}"
#FOLDERID_favorites = "{1777f761-68ad-4d8a-87bd-30b759fa33dd}"
#FOLDERID_fonts = "{fd228cb7-ae11-4ae3-864c-16f3910ab8fe}"
#FOLDERID_games = "{cac52c1a-b53d-4edc-92d7-6b2e8ac19434}"
#FOLDERID_gametasks = "{054fae61-4dd8-4787-80b6-090220c4b700}"
#FOLDERID_history = "{d9dc8a3b-b784-432e-a781-5a1130a75963}"
#FOLDERID_homegroup = "{52528a6b-b9e3-4add-b60d-588c2dba842d}"
#FOLDERID_homegroupcurrentuser = "{9b74b6a3-0dfd-4f11-9e78-5f7800f2e772}"
#FOLDERID_implicitappshortcuts = "{bcb5256f-79f6-4cee-b725-dc34e402fd46}"
#FOLDERID_internetcache = "{352481e8-33be-4251-ba85-6007caedcf9d}"
#FOLDERID_internetfolder = "{4d9f7874-4e0c-4904-967b-40b0d20c3e4b}"
#FOLDERID_libraries = "{1b3ea5dc-b587-4786-b4ef-bd1dc332aeae}"
#FOLDERID_links = "{bfb9d5e0-c6a9-404c-b2b2-ae6db6af4968}"
#FOLDERID_localappdata = "{f1b32785-6fba-4fcf-9d55-7b8e7f157091}"
#FOLDERID_localappdatalow = "{a520a1a4-1780-4ff6-bd18-167343c5af16}"
#FOLDERID_localizedresourcesdir = "{2a00375e-224c-49de-b8d1-440df7ef3ddc}"
#FOLDERID_music = "{4bd8d571-6d19-48d3-be97-422220080e43}"
#FOLDERID_musiclibrary = "{2112ab0a-c86a-4ffe-a368-0de96e47012e}"
#FOLDERID_nethood = "{c5abbf53-e17f-4121-8900-86626fc2c973}"
#FOLDERID_networkfolder = "{d20beec4-5ca8-4905-ae3b-bf251ea09b53}"
#FOLDERID_objects3d = "{31c0dd25-9439-4f12-bf41-7ff4eda38722}"
#FOLDERID_originalimages = "{2c36c0aa-5812-4b87-bfd0-4cd0dfb19b39}"
#FOLDERID_photoalbums = "{69d2cf90-fc33-4fb7-9a0c-ebb0f0fcb43c}"
#FOLDERID_pictures = "{33e28130-4e1e-4676-835a-98395c3bc3bb}"
#FOLDERID_pictureslibrary = "{a990ae9f-a03b-4e80-94bc-9912d7504104}"
#FOLDERID_playlists = "{de92c1c7-837f-4f69-a3bb-86e631204a23}"
#FOLDERID_printersfolder = "{76fc4e2d-d6ad-4519-a663-37bd56068185}"
#FOLDERID_printhood = "{9274bd8d-cfd1-41c3-b35e-b13f55a758f4}"
#FOLDERID_profile = "{5e6c858f-0e22-4760-9afe-ea3317b67173}"
#FOLDERID_programdata = "{62ab5d82-fdc1-4dc3-a9dd-070d1d495d97}"
#FOLDERID_programfiles = "{905e63b6-c1bf-494e-b29c-65b732d3d21a}"
#FOLDERID_programfilesx64 = "{6d809377-6af0-444b-8957-a3773f02200e}"
#FOLDERID_programfilesx86 = "{7c5a40ef-a0fb-4bfc-874a-c0f2e0b9fa8e}"
#FOLDERID_programfilescommon = "{f7f1ed05-9f6d-47a2-aaae-29d317c6f066}"
#FOLDERID_programfilescommonx64 = "{6365d5a7-0f0d-45e5-87f6-0da56b6a4f7d}"
#FOLDERID_programfilescommonx86 = "{de974d24-d9c6-4d3e-bf91-f4455120b917}"
#FOLDERID_programs = "{a77f5d77-2e2b-44c3-a6a2-aba601054a51}"
#FOLDERID_public = "{dfdf76a2-c82a-4d63-906a-5644ac457385}"
#FOLDERID_publicdesktop = "{c4aa340d-f20f-4863-afef-f87ef2e6ba25}"
#FOLDERID_publicdocuments = "{ed4824af-dce4-45a8-81e2-fc7965083634}"
#FOLDERID_publicdownloads = "{3d644c9b-1fb8-4f30-9b45-f670235f79c0}"
#FOLDERID_publicgametasks = "{debf2536-e1a8-4c59-b6a2-414586476aea}"
#FOLDERID_publiclibraries = "{48daf80b-e6cf-4f4e-b800-0e69d84ee384}"
#FOLDERID_publicmusic = "{3214fab5-9757-4298-bb61-92a9deaa44ff}"
#FOLDERID_publicpictures = "{b6ebfb86-6907-413c-9af7-4fc2abf07cc5}"
#FOLDERID_publicringtones = "{e555ab60-153b-4d17-9f04-a5fe99fc15ec}"
#FOLDERID_publicusertiles = "{0482af6c-08f1-4c34-8c90-e17ec98b1e17}"
#FOLDERID_publicvideos = "{2400183a-6185-49fb-a2d8-4a392a602ba3}"
#FOLDERID_quicklaunch = "{52a4f021-7b75-48a9-9f6b-4b87a210bc8f}"
#FOLDERID_recent = "{ae50c081-ebd2-438a-8655-8a092e34987a}"
#FOLDERID_recordedtvlibrary = "{1a6fdba2-f42d-4358-a798-b74d745926c5}"
#FOLDERID_recyclebinfolder = "{b7534046-3ecb-4c18-be4e-64cd4cb7d6ac}"
#FOLDERID_resourcedir = "{8ad10c31-2adb-4296-a8f7-e4701232c972}"
#FOLDERID_ringtones = "{c870044b-f49e-4126-a9c3-b52a1ff411e8}"
#FOLDERID_roamedtileimages = "{aaa8d5a5-f1d6-4259-baa8-78e7ef60835e}"
#FOLDERID_roamingappdata = "{3eb685db-65f9-4cf6-a03a-e3ef65729f3d}"
#FOLDERID_roamingtiles = "{00bcfc5a-ed94-4e48-96a1-3f6217f21990}"
#FOLDERID_samplemusic = "{b250c668-f57d-4ee1-a63c-290ee7d1aa1f}"
#FOLDERID_samplepictures = "{c4900540-2379-4c75-844b-64e6faf8716b}"
#FOLDERID_sampleplaylists = "{15ca69b3-30ee-49c1-ace1-6b5ec372afb5}"
#FOLDERID_samplevideos = "{859ead94-2e85-48ad-a71a-0969cb56a6cd}"
#FOLDERID_savedgames = "{4c5c32ff-bb9d-43b0-b5b4-2d72e54eaaa4}"
#FOLDERID_savedpictures = "{3b193882-d3ad-4eab-965a-69829d1fb59f}"
#FOLDERID_savedpictureslibrary = "{e25b5812-be88-4bd9-94b0-29233477b6c3}"
#FOLDERID_savedsearches = "{7d1d3a04-debb-4115-95cf-2f29da2920da}"
#FOLDERID_screenshots = "{b7bede81-df94-4682-a7d8-57a52620b86f}"
#FOLDERID_search_csc = "{ee32e446-31ca-4aba-814f-a5ebd2fd6d5e}"
#FOLDERID_search_mapi = "{98ec0e18-2098-4d44-8644-66979315a281}"
#FOLDERID_searchhistory = "{0d4c3db6-03a3-462f-a0e6-08924c41b5d4}"
#FOLDERID_searchhome = "{190337d1-b8ca-4121-a639-6d472d16972a}"
#FOLDERID_searchtemplates = "{7e636bfe-dfa9-4d5e-b456-d7b39851d8a9}"
#FOLDERID_sendto = "{8983036c-27c0-404b-8f08-102d10dcfd74}"
#FOLDERID_sidebardefaultparts = "{7b396e54-9ec5-4300-be0a-2482ebae1a26}"
#FOLDERID_sidebarparts = "{a75d362e-50fc-4fb7-ac2c-a8beaa314493}"
#FOLDERID_skydrive = "{a52bba46-e9e1-435f-b3d9-28daa648c0f6}"
#FOLDERID_skydrivecameraroll = "{767e6811-49cb-4273-87c2-20f355e1085b}"
#FOLDERID_skydrivedocuments = "{24d89e24-2f19-4534-9dde-6a6671fbb8fe}"
#FOLDERID_skydrivepictures = "{339719b5-8c47-4894-94c2-d8f77add44a6}"
#FOLDERID_startmenu = "{625b53c3-ab48-4ec1-ba1f-a1ef4146fc19}"
#FOLDERID_startup = "{b97d20bb-f46a-4c97-ba10-5e3608430854}"
#FOLDERID_syncmanagerfolder = "{43668bf8-c14e-49b2-97c9-747784d784b7}"
#FOLDERID_syncresultsfolder = "{289a9a43-be44-4057-a41b-587a76d7e7f9}"
#FOLDERID_syncsetupfolder = "{0f214138-b1d3-4a90-bba9-27cbc0c5389a}"
#FOLDERID_system = "{1ac14e77-02e7-4e5d-b744-2eb1ae5198b7}"
#FOLDERID_systemx86 = "{d65231b0-b2f1-4857-a4ce-a8e7c6ea7d27}"
#FOLDERID_templates = "{a63293e8-664e-48db-a079-df759e0509f7}"
#FOLDERID_userpinned = "{9e3995ab-1f9c-4f13-b827-48b24b6c7174}"
#FOLDERID_userprofiles = "{0762d272-c50a-4bb0-a382-697dcd729b80}"
#FOLDERID_userprogramfiles = "{5cd7aee2-2219-4a67-b85d-6c9ce15660cb}"
#FOLDERID_userprogramfilescommon = "{bcbd3057-ca5c-4622-b42d-bc56db0ae516}"
#FOLDERID_usersfiles = "{f3ce0f7c-4901-4acc-8648-d5d44b04ef8f}"
#FOLDERID_userslibraries = "{a302545d-deff-464b-abe8-61c8648d939b}"
#FOLDERID_videos = "{18989b1d-99b5-455b-841c-ab7c74e4ddfc}"
#FOLDERID_videoslibrary = "{491e922f-5643-4af4-a7eb-4e7a138d8174}"
#FOLDERID_windows = "{f38bf404-1d43-42f2-9305-67de0b28fc23}"
#KF_FLAG_SIMPLE_IDLIST = $00000100
#KF_FLAG_NOT_PARENT_RELATIVE = $00000200
#KF_FLAG_DEFAULT_PATH = $00000400
#KF_FLAG_INIT = $00000800
#KF_FLAG_NO_ALIAS = $00001000
#KF_FLAG_DONT_UNEXPAND = $00002000
#KF_FLAG_DONT_VERIFY = $00004000
#KF_FLAG_CREATE = $00008000
#KF_FLAG_NO_APPCONTAINER_REDIRECTION = $00010000 ; <- Introduced in Windows 7.
#KF_FLAG_ALIAS_ONLY = $80000000
DeclareModule GetKnownFolderPath
Declare.s GetKnownFolderPath(guid.s, kfFlag.l = 0, hToken.i = #Null)
EndDeclareModule
Module GetKnownFolderPath
Prototype.i ProtoSHGetKnownFolderPath(*rfid, dwFlags.l ,hToken.i, *ppszPath)
Structure sRFID
long1.l
word1.w
word2.w
byte1.b
byte2.b
byte3.b
byte4.b
byte5.b
byte6.b
byte7.b
byte8.b
EndStructure
Global regexWordNum = CreateRegularExpression(#PB_Any,"(\w|\s)*\w(?="+#DQUOTE$+")|\w+")
Procedure.s GetWordNum( StringToCheck.s, wordnum.i)
Dim wordList.s(0)
If ExtractRegularExpression(regexWordNum,StringToCheck,wordList())
If wordnum <= ArraySize(wordList())+1
ProcedureReturn wordList( wordnum-1 )
EndIf
EndIf
EndProcedure
Procedure.s GetKnownFolderPath(guid.s, kfFlag.l = 0, hToken.i = #Null)
Protected SHGetKnownFolderPath.ProtoSHGetKnownFolderPath
Protected hLib.i, RetVal.i, sFolderPath.s, *Path
Protected rfid.sRFID, tmp.s
With rfid
\long1 = Val("$"+GetWordNum(guid,1))
\word1 = Val("$"+GetWordNum(guid,2))
\word2 = Val("$"+GetWordNum(guid,3))
tmp = RSet(GetWordNum(guid,4),4,"0")
\byte1 = Val("$"+Left(tmp,2))
\byte2 = Val("$"+Right(tmp,2))
tmp = RSet(GetWordNum(guid,5),12,"0")
\byte3 = Val("$"+Left(tmp,2))
\byte4 = Val("$"+Mid(tmp,3,2))
\byte5 = Val("$"+Mid(tmp,5,2))
\byte6 = Val("$"+Mid(tmp,7,2))
\byte7 = Val("$"+Mid(tmp,9,2))
\byte8 = Val("$"+Mid(tmp,11,2))
EndWith
hLib = OpenLibrary(#PB_Any, "shell32.dll")
If hLib
SHGetKnownFolderPath = GetFunction(hLib, "SHGetKnownFolderPath")
If SHGetKnownFolderPath
RetVal = SHGetKnownFolderPath(@rfid, kfFlag, hToken, @*Path)
If (RetVal = #S_OK) And *Path
sFolderPath = PeekS(*Path, -1, #PB_Unicode)
CoTaskMemFree_(*Path)
If sFolderPath
sFolderPath + "\"
EndIf
EndIf
EndIf
CloseLibrary(hLib)
EndIf
ProcedureReturn sFolderPath
EndProcedure
EndModule
CompilerIf #PB_Compiler_IsMainFile
UseModule GetKnownFolderPath
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_desktop)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_documents)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_publicdocuments)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_localappdata)
;added by Jan2004
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_fonts)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_admintools)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_videoslibrary)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_internetcache)
Debug GetKnownFolderPath::GetKnownFolderPath(#FOLDERID_applicationshortcuts)
CompilerEndIf
lines 4 to 123:
#FOLDERID_accountpictures = "{008ca0b1-55b4-4c56-b8a8-4de4b299d3be}"
#FOLDERID_addnewprograms = "{de61d971-5ebc-4f02-a3a9-6c82895e5c04}"
and further.
What versions of Windows will this work on?
line 189:
hLib = OpenLibrary(#PB_Any, "shell32.dll")
Does this also work on Windows 64?
Re: Which directory should I choose to store data files created in my application?
Yes, it certainly does work on W64Jan2004 wrote: Sat Jul 22, 2023 7:24 am Jim, I decided to show your solution from the quoted post:
line 189:
hLib = OpenLibrary(#PB_Any, "shell32.dll")
Does this also work on Windows 64?
Not all the folders are on all versions of Windows. I only use the two referred to above.
Jim