Skip to content

Win32 package should bind SHGetFolderPath

Currently Cabal binds this function so that we can find the "Program Files" directory on Windows:

foreign import stdcall unsafe "shlobj.h SHGetFolderPathA"
 c_SHGetFolderPath :: Ptr () -> CInt -> Ptr () -> CInt -> CString -> IO CInt

This is fine except that it does not work in ghci because we have no way to tell ghci that it would need to link to shell32.dll. As it happens we do not have to tell the static linker to use shell32.dll because it appears to link to it by default. This of course means that runghc Setup does not work on Windows for Cabal itself which trips up many users. The fact that the README tells people to use ghc --make Setup instead doesn't help a great deal. See Cabal ticket #325

What would be nice is if the Win32 package would bind SHGetFolderPath. Then we just import it from the Win32 package and it'll work in ghci. Apparently, according to MSDN, this function is technically deprecated, however the replacement SHGetKnownFolderPath is only available in Vista and later so we probably need to bind it anyway. Note that SHGetFolderPath is in shell32.dll except on Windows 2000 which include it in SHFolder.dll which come with IE4 and later.

Trac metadata
Trac field Value
Version 6.10.1
Type FeatureRequest
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component libraries (other)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information