Page 1 of 1
SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 12:04 am
by alphadennis
SHGetPathFromIDList_(Result, @Folder) does not work in the current PureBasic 6.11 LTS (Windows - x64).
It does not give me an error and just terminates the run and puts me back to the windows screen
It worked in my compiled EXE on 5/282023.
What is the new purebasic function?
Windows has SHGetPathFromIDListA and SHGetPathFromIDListW and has discontinued SHGetPathFromIDList_
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 1:51 am
by Demivec
Do you have some code to demonstrate your problems?
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 7:40 am
by firace
alphadennis wrote: Mon Aug 05, 2024 12:04 am
SHGetPathFromIDList_(Result, @Folder) does not work in the current PureBasic 6.11 LTS (Windows - x64).
It does not give me an error and just terminates the run and puts me back to the windows screen
It worked in my compiled EXE on 5/282023.
What is the new purebasic function?
Windows has SHGetPathFromIDListA and SHGetPathFromIDListW and has discontinued SHGetPathFromIDList_
Can you try this code (by normeus)? Works fine for me:
Code: Select all
Define Folder_ID, SFolderLoc.s
If SHGetSpecialFolderLocation_(0, #CSIDL_PROFILE, @Folder_ID) = 0
SFolderLoc.s = Space(#MAX_PATH*2)
SHGetPathFromIDList_(Folder_ID, @SFolderLoc)
CoTaskMemFree_(Folder_ID)
EndIf
Debug sFolderLoc
Note: I'm still running 6.03.
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 8:47 am
by Fred
First thing to check is if you are still using '.l' for variable which handle pointers (should be '.i' or no suffix)
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 8:52 am
by Captn. Jinguji
firace wrote: Mon Aug 05, 2024 7:40 am
Can you try this code (by normeus)? Works fine for me:
Code: Select all
Define Folder_ID, SFolderLoc.s
If SHGetSpecialFolderLocation_(0, #CSIDL_PROFILE, @Folder_ID) = 0
SFolderLoc.s = Space(#MAX_PATH*2)
SHGetPathFromIDList_(Folder_ID, @SFolderLoc)
CoTaskMemFree_(Folder_ID)
EndIf
Debug sFolderLoc
Note: I'm still running 6.03.
That code is working fine here on 6.11 64-bit, win 11. (also tested with some other #CSIDL-Constants)
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 6:24 pm
by alphadennis
Here is my code. It fails at SHGetPathFromIDList_ becuase MessageRequester("exiting pathrequest","SHGetPathFromIDList") is never hit.
Folder is set in
Global Folder.s
Code: Select all
#BIF_RETURNONLYFSDIRS = 1;
#BIF_DONTGOBELOWDOMAIN = 2;
#BIF_STATUSTEXT = 4;
#BIF_RETURNFSANCESTORS = 8;
#BIF_EDITBOX = 16;
;#BIF_VALIDATE = 32;
#BIF_NEWDIALOGSTYLE = 64;
#BIF_BROWSEINCLUDEURLS = 128;
;;#BIF_USENEWUI = #BIF_EDITBOX | #BIF_NEWDIALOGSTYLE
#BIF_BROWSEFORCOMPUTER = $1000;
#BIF_BROWSEFORPRINTER = $2000;
#BIF_BROWSEINCLUDEFILES = $4000;
#BIF_SHAREABLE = $8000;
#BFFM_INITIALIZED = 1;
#BFFM_SELCHANGED = 2;
#BFFM_VALIDATEFAILEDA = 3;
#BFFM_VALIDATEFAILEDW = 4;
#BFFM_SETSTATUSTEXTA = #WM_USER + 100;
#BFFM_ENABLEOK = #WM_USER + 101;
#BFFM_SETSELECTIONA = #WM_USER + 102;
#BFFM_SETSELECTIONW = #WM_USER + 103;
#BFFM_SETSTATUSTEXTW = #WM_USER + 104;
#BFFM_SETOKTEXT = #WM_USER + 105;
#BFFM_SETEXPANDED = #WM_USER + 106
Global STYLE
#BIF_BROWSEFILEJUNCTIONS = $00010000
CompilerIf #PB_Compiler_Unicode
STYLE = #BFFM_SETSELECTIONW
CompilerElse
STYLE = #BFFM_SETSELECTIONA
CompilerEndIf
Procedure PathRequesterCallback(hWnd, msg, lParam, lData)
Select msg
Case #BFFM_INITIALIZED
;SetWindowPos_(hWnd, #HWND_TOPMOST , -1,-1,-1,-1, #SWP_NOSIZE | #SWP_NOMOVE)
If lData
SendMessage_ (hWnd, STYLE, 1, lData)
Delay(100)
PostMessage_ (hWnd, STYLE, 1, lData)
EndIf
EndSelect
EndProcedure
Procedure.s PathRequesterAPI( Title.s, InitialPath.s)
Folder = Space(#MAX_PATH)
Protected bi.BROWSEINFO
;bi\ulFlags = #BIF_EDITBOX |#BIF_NEWDIALOGSTYLE
bi\ulFlags = #BIF_RETURNONLYFSDIRS |#BIF_DONTGOBELOWDOMAIN | #BIF_RETURNFSANCESTORS | #BIF_STATUSTEXT
bi\lpfn = @PathRequesterCallback()
bi\lParam = @InitialPath
bi\lpszTitle = @Title
Protected Result.L=SHBrowseForFolder_(@bi)
;MessageRequester("exiting pathrequest","SHBrowseForFolder")
SHGetPathFromIDList_(Result, @Folder)
MessageRequester("exiting pathrequest","SHGetPathFromIDList")
CoTaskMemFree_(Result)
ProcedureReturn Folder
EndProcedure
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 6:30 pm
by alphadennis
firace wrote: Mon Aug 05, 2024 7:40 am
alphadennis wrote: Mon Aug 05, 2024 12:04 am
SHGetPathFromIDList_(Result, @Folder) does not work in the current PureBasic 6.11 LTS (Windows - x64).
It does not give me an error and just terminates the run and puts me back to the windows screen
It worked in my compiled EXE on 5/282023.
What is the new purebasic function?
Windows has SHGetPathFromIDListA and SHGetPathFromIDListW and has discontinued SHGetPathFromIDList_
Can you try this code (by normeus)? Works fine for me:
Code: Select all
Define Folder_ID, SFolderLoc.s
If SHGetSpecialFolderLocation_(0, #CSIDL_PROFILE, @Folder_ID) = 0
SFolderLoc.s = Space(#MAX_PATH*2)
SHGetPathFromIDList_(Folder_ID, @SFolderLoc)
CoTaskMemFree_(Folder_ID)
EndIf
Debug sFolderLoc
Note: I'm still running 6.03.
OK I'll try this. Thanks
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 7:12 pm
by HeX0R
Code: Select all
Protected Result.L=SHBrowseForFolder_(@bi)
This is wrong, Result needs to be an integer
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 11:09 pm
by alphadennis
Many thanks! Result.i worked in 6.11 LTS (Windows - x64)
Don't know why Result.L workeked in 2023 versions and not this version?
Re: SHGetPathFromIDList_ not working
Posted: Mon Aug 05, 2024 11:12 pm
by alphadennis
Fred wrote: Mon Aug 05, 2024 8:47 am
First thing to check is if you are still using '.l' for variable which handle pointers (should be '.i' or no suffix)
Thanks, Result.i worked in 6.11 LTS (Windows - x64)
Don't lnow why Result/L worked ok in earlier versions.
Re: SHGetPathFromIDList_ not working
Posted: Tue Aug 06, 2024 8:40 am
by Fred
It's because 6.10+ enabled the high entropy flag for allocated memory for 64-bit executable on Windows to avoid memory based attacks. The result of this is the memory pointer can now be very random with value much bigger than 32-bit and it doesn't fit in a .l anymore.