alank2 5 Posted March 13, 2023 I am trying to get the programdata folder. I've been using: cppbuilder 10.3.3 LPITEMIDLIST pidl SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_APPDATA, &pidl) SHGetPathFromIDListW(pidl, APath) This works fine in a VCL application, but a FireMonkey application, none of it is recognized. I tried to include <shlobj_core.h>, but this gives 1500+ warnings about the below and then fails. [bcc32 Warning] shobjidl_core.h(26477): W8026 Functions with exception specifications are not expanded inline Full parser context mycode.cpp(33): #include c:\program files (x86)\embarcadero\studio\20.0\include\windows\sdk\shlobj_core.h shlobj_core.h(86): #include c:\program files (x86)\embarcadero\studio\20.0\include\windows\sdk\shobjidl_core.h shobjidl_core.h(26477): decision to instantiate: ACTIVATEOPTIONS |(ACTIVATEOPTIONS,ACTIVATEOPTIONS) throw() --- Resetting parser context for instantiation... I was using this function because this code has to run on some older compilers, but if I can't get it to work I can use something else. Share this post Link to post
alank2 5 Posted March 13, 2023 I found this page: https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Standard_RTL_Path_Functions_across_the_Supported_Target_Platforms And then found this: UnicodeString us; us=System::Ioutils::TPath::GetPublicPath(); Share this post Link to post
Remy Lebeau 1398 Posted March 13, 2023 30 minutes ago, alank2 said: LPITEMIDLIST pidl SHGetSpecialFolderLocation(NULL, CSIDL_COMMON_APPDATA, &pidl) SHGetPathFromIDListW(pidl, APath) This works fine in a VCL application, but a FireMonkey application, none of it is recognized. Correct, since FMX is cross-platform, but you are trying to use platform-specific code. So, you will have to #ifdef your code for Windows, and then #include the relevant header files, in this case <windows.h> and <shlobj.h> (NOT <shlobj_core.h> directly). Also, FYI, SHGetSpecialFolderLocation() is very old, so you should be using SHGetFolderPathW() instead, or even SHGetKnownFolderPath(). 30 minutes ago, alank2 said: [bcc32 Warning] shobjidl_core.h(26477): W8026 Functions with exception specifications are not expanded inline That is just a warning. Ignore it, and or turn it off in the compiler settings. 30 minutes ago, alank2 said: I was using this function because this code has to run on some older compilers SHGetFolderPath() was introduced in Windows 2000. Any old compiler that doesn't recognize it is too old to support FireMonkey anyway. 1 Share this post Link to post
alank2 5 Posted March 13, 2023 Thank you - I disabled the warnings and that did solve the problem: #pragma warn -8026 #pragma warn -8027 #include <shlobj_core.h> #pragma warn .8027 #pragma warn .8026 I like that better than my other approach. Share this post Link to post