SHGetPathFromIDList_ not working

Just starting out? Need help? Post your questions and find answers here.
alphadennis
New User
New User
Posts: 5
Joined: Sun Aug 04, 2024 11:56 pm

SHGetPathFromIDList_ not working

Post 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_
User avatar
Demivec
Addict
Addict
Posts: 4266
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: SHGetPathFromIDList_ not working

Post by Demivec »

Do you have some code to demonstrate your problems?
firace
Addict
Addict
Posts: 946
Joined: Wed Nov 09, 2011 8:58 am

Re: SHGetPathFromIDList_ not working

Post 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.
Fred
Administrator
Administrator
Posts: 18178
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SHGetPathFromIDList_ not working

Post by Fred »

First thing to check is if you are still using '.l' for variable which handle pointers (should be '.i' or no suffix)
Captn. Jinguji
User
User
Posts: 94
Joined: Sun Oct 24, 2004 9:25 am

Re: SHGetPathFromIDList_ not working

Post by Captn. Jinguji »

firace wrote: Mon Aug 05, 2024 7:40 am
alphadennis wrote: Mon Aug 05, 2024 12:04 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)
Is this an artifact or should it be disposed of ?
alphadennis
New User
New User
Posts: 5
Joined: Sun Aug 04, 2024 11:56 pm

Re: SHGetPathFromIDList_ not working

Post 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
alphadennis
New User
New User
Posts: 5
Joined: Sun Aug 04, 2024 11:56 pm

Re: SHGetPathFromIDList_ not working

Post 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
User avatar
HeX0R
Addict
Addict
Posts: 1198
Joined: Mon Sep 20, 2004 7:12 am
Location: Hell

Re: SHGetPathFromIDList_ not working

Post by HeX0R »

Code: Select all

Protected Result.L=SHBrowseForFolder_(@bi)
This is wrong, Result needs to be an integer
alphadennis
New User
New User
Posts: 5
Joined: Sun Aug 04, 2024 11:56 pm

Re: SHGetPathFromIDList_ not working

Post 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?
alphadennis
New User
New User
Posts: 5
Joined: Sun Aug 04, 2024 11:56 pm

Re: SHGetPathFromIDList_ not working

Post 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.
Fred
Administrator
Administrator
Posts: 18178
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: SHGetPathFromIDList_ not working

Post 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.
Post Reply