Author Topic: [Haiku] use find_directory instead of getenv to determine home directory  (Read 10018 times)

0 Members and 1 Guest are viewing this topic.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8752
  • Total likes: 305
  • Helpful: 229
  • Languages: De,EN,JP
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #35 on: September 02, 2015, 08:56:35 PM »
SHGetFolderPath is also used for the program directory in simwin_w just below. If MSVC 2015 does not compile SHGetFolderA, then obviously we need to change this. But obtaining the program folder did works. Hence if we use it in one place, why not using it in the other?

And SHGetFOlderPath compiled on older systems is a dynamical linked function; hence this function will not be removed from the kernel until all 32 bit applications die out (maye around 2025 given how long 16 bit programs did work).

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4677
  • Total likes: 170
  • Helpful: 108
  • Languages: EN, NO
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #36 on: September 03, 2015, 05:56:50 AM »
And SHGetFOlderPath compiled on older systems is a dynamical linked function; hence this function will not be removed from the kernel until all 32 bit applications die out (maye around 2025 given how long 16 bit programs did work).

It is still a dynamically linked function (well SHGetFolderPathA and SHGetFolderPathW are, SHGetFolderPath is and has always been a macro). As far as I know, everything in Win32 is either that or a COM interface. (And it's not part of the kernel. The kernel API is mostly undocumented, apart from what drivers use.)

Curiously, the predecessor to SHGetFolderPath, SHGetSpecialFolderPath, is still documented on MSDN despite being replaced, and likely deprecated, 15 years ago. I'm not sure when support ended, but it's clearly of the "it might still work, but we won't help you if it doesn't (except when we do)" kind if one knows Microsoft's history of compatibility. (Not that there is any reason for us whatsoever to even consider using SHGetSpecialFolderPath anymore.)

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15452
  • Total likes: 378
  • Helpful: 171
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #37 on: September 03, 2015, 09:20:07 AM »
I managed to get this to compile on MSVS 2012 by adding the following line to simsys.cc (in the #ifdef _WIN32 section):

#   include <shlobj.h>      // needed for SHGetFolderPath()
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 8752
  • Total likes: 305
  • Helpful: 229
  • Languages: De,EN,JP
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #38 on: September 03, 2015, 09:26:53 AM »
Which you are talking of? simsys.cc already used SHGetFolderPath and included the latter? simsys_posix should not need any of this, as it uses simsys.cc too (if everything is compiled as intended.)

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15452
  • Total likes: 378
  • Helpful: 171
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #39 on: September 03, 2015, 12:25:07 PM »
I refer to simsys.cc - my copy (for Experimental) did not include slobj.h, and adding this line allowed it to compile - if this had already been added to Standard and I managed to miss it for Experimental, then this may not assist with issues in Standard (which I had inferred was that MSVS 2015 was not compiling with this line) as much as I had hoped.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4677
  • Total likes: 170
  • Helpful: 108
  • Languages: EN, NO
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #40 on: September 03, 2015, 02:17:55 PM »
shlobj.h was added to simsys.cc over a year ago, in order to locate the font directory.

Offline jamespetts

  • Simitrans-Extended project coordinator
  • Devotee
  • *
  • Posts: 15452
  • Total likes: 378
  • Helpful: 171
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #41 on: September 03, 2015, 03:02:39 PM »
Ah - I appear to be behind. Perhaps this is because I have never managed to merge the GUI themes code?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Ters

  • Coder/patcher
  • Devotee
  • *
  • Posts: 4677
  • Total likes: 170
  • Helpful: 108
  • Languages: EN, NO
Re: [Haiku] use find_directory instead of getenv to determine home directory
« Reply #42 on: September 12, 2015, 09:54:44 PM »
It is curious that despite lots of changes having been done to how Simutrans gets the documents directory on Windows, the request that started the Windows-related changes, that we should not go digging into the registry for undocumented registry keys, has not been acted upon. Despite being the most likely not to work, it is still in there as a Plan B.