I need a PathRequester() WITHOUT a built-in option to create a new folder. I've rewritten my installer
program, and ran into a problem when testing.
If a user installs in for example 'Program Files', I can safely remove the subfolder the program was
installed in, but not the 'Program Files' folder itself of course.
But if the user creates a new folder using the Path requester, and installs in it, I can't remove it.
I can remove the program folder, but am not shure what to do about the parent folder the user created.
I could delete the parent folder if it is empty when the program is uninstalled, but the user might have
a reason for creating the folder in the first place, empty or not, so I'm not shure?
Anyway, this problem goes away if the user is simply left with the choice to pick another folder to install
in, instead of beeing able to create a new one, hence the request.
I guess this could be done with som API and some appopriate constants.?
Pathrequester W/O create new folder option?
- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
Code: Select all
Procedure BrowseCallbackProc(hwnd, msg, lParam, lData)
szDir$ = Space(#MAX_PATH)
Select msg
Case #BFFM_INITIALIZED
SendMessage_(hwnd, #BFFM_SETSELECTION, #BFFM_INITIALIZED, lData)
Case #BFFM_SELCHANGED
If SHGetPathFromIDList_(lParam, @szDir$)
SendMessage_(hwnd, #BFFM_SETSTATUSTEXT, 0, @szDir$)
EndIf
EndSelect
EndProcedure
Procedure.s BrowseForFolder(Style, Titel.s, Path.s)
Folder.s = Space(#MAX_PATH)
Dir.BROWSEINFO
Dir\hwndOwner = GetActiveWindow_()
Dir\pszDisplayName = @Folder
Dir\lpszTitle = @Titel
Dir\ulFlags = Style
Dir\lpfn = @BrowseCallbackProc()
Dir\lParam = @Path
result.l = SHBrowseForFolder_(@Dir)
SHGetPathFromIDList_(result, @Folder)
If Folder <> ""
If FileSize(Folder) = - 2
If Right(Folder, 1) <> "\" : Folder + "\" : EndIf
EndIf
EndIf
CoTaskMemFree_(result)
ProcedureReturn Folder
EndProcedure
Style = #BIF_STATUSTEXT | #BIF_BROWSEINCLUDEFILES
BrowseForFolder(Style, "Please choose your path", "")
http://msdn.microsoft.com/library/defau ... seinfo.asp
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

- utopiomania
- Addict
- Posts: 1655
- Joined: Tue May 10, 2005 10:00 pm
- Location: Norway
@ts-soft, thanks for the code sample. I've archived it for later use.
@Trond, I agree. I came to the same conclusion myself. If the user browses to a new location
and creates a folder there, it's probably his responsibility to delete it after an uninstall
or use it for some other purpose later.
So I think I will leave the 'create new folder' button in place for convinience, and ignore
folders created with it.
The way the uninstaller works now, it will remove everything the installer puts on disk or in
the registry. Extra files created somewhere in the target folder structure will be listed, and
the user is given a choice to remove all or keep them.
Thanks for the help!
@Trond, I agree. I came to the same conclusion myself. If the user browses to a new location
and creates a folder there, it's probably his responsibility to delete it after an uninstall
or use it for some other purpose later.
So I think I will leave the 'create new folder' button in place for convinience, and ignore
folders created with it.
The way the uninstaller works now, it will remove everything the installer puts on disk or in
the registry. Extra files created somewhere in the target folder structure will be listed, and
the user is given a choice to remove all or keep them.
Thanks for the help!