Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Get path to common program data folder

Author
Message
Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 15th Oct 2011 19:16
Hello all

I'm using the following code to get the path to the local progdata folder. On my Win7 system the result is C:\ProgramData.




My question is - is this the best way to do this? It seemed a bit unreliable on some networked WinXP systems which were members of a domain.

Thanks for any advice

James
Rich Dersheimer
AGK Developer
17
Years of Service
User Offline
Joined: 1st Jul 2009
Location: Inside the box
Posted: 15th Oct 2011 19:28 Edited at: 15th Oct 2011 19:28
I think there's commands for this kind of stuff in IanM's matrix utilities plugin.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 15th Oct 2011 19:35
In section 24 of IanM's Matrix1 Utilities Plugins has several commands to get directories used by Windows but ProgramData isn't one of them. You could check which version of Windows is currently running then pick a different routine to get that directory... but I don't think XP even uses a ProgramData directory.

If you don't have IanM's Matrix1 Utilities Plugins by now how the heck have you survived this long without oxygen??!! Download it now and breath easier.
https://forumfiles.thegamecreators.com/download/2257747

Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 15th Oct 2011 21:13
Thanks for the replies, Rich and Grog.

I do have IanM's Matrix plugins - couldn't survive without them!

The code posted above does map to 'application data' (I think) on WinXP. But I'm looking for a more elegant way to do it, as it doesn't always seem to work on XP computers which are on a domain. Dunno why.
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 15th Oct 2011 23:08
When you call SHGetFolderLocation, you are passing in two empty strings - that's definitely wrong for that function. Pass in zeros for those two parameters instead and see if that fixes your problem.

As an alternative to calling SHGetFolderLocation and SHGetPathFromIDList, why not just call SHGetFolderPath?

Also, you can use PEEK STRING on the result rather than grab the characters one at a time from your buffer.

@Grog,
Quote: "ProgramData isn't one of them"

It isn't currently, but will be in the next release. Plus there will be a more general way to access folder locations so that I don't have to keep adding new functions to the plug-in.

Jambo B
16
Years of Service
User Offline
Joined: 17th Sep 2009
Location: The Pit
Posted: 16th Oct 2011 03:09
IanM - thanks, what you've said makes good sense - I'll have a mess around with it.

Looking forward to the next release of your Matrix plugins You do the community a great (and much appreciated) service.
WLGfx
18
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 16th Oct 2011 04:15
Quote: "You do the community a great (and much appreciated) service."
Vote from me too...

Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 16th Oct 2011 06:02
Quote: "It isn't currently, but will be in the next release. Plus there will be a more general way to access folder locations so that I don't have to keep adding new functions to the plug-in."


Cool.

Login to post a reply

Server time is: 2026-07-11 14:37:45
Your offset time is: 2026-07-11 14:37:45