diff --git a/src/Makefile.global.in b/src/Makefile.global.in
index 7648dba1723b22909c43c45e4559c0f4172728df..0a60a54ca1543ee1616ddbaf4d24cc361923172d 100644
--- a/src/Makefile.global.in
+++ b/src/Makefile.global.in
@@ -549,10 +549,9 @@ LIBOBJS = @LIBOBJS@
 
 LIBS := -lpgcommon -lpgport $(LIBS)
 
-# to make ws2_32.lib the last library, and always link with shfolder,
-# so SHGetFolderName isn't picked up from shell32.dll
+# to make ws2_32.lib the last library
 ifeq ($(PORTNAME),win32)
-LIBS += -lws2_32 -lshfolder
+LIBS += -lws2_32
 endif
 
 # Not really standard libc functions, used by the backend.
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index c99faac42e4099662ebf2f23b1a726ba95d107c1..43b76f697bda014ef11f8239582c8b291a4b01df 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -39,11 +39,6 @@ SHLIB_PREREQS = submake-libpq submake-pgtypeslib
 
 SHLIB_EXPORTS = exports.txt
 
-ifeq ($(PORTNAME), win32)
-# Link to shfolder.dll instead of shell32.dll
-SHLIB_LINK += -lshfolder
-endif
-
 PKG_CONFIG_REQUIRES_PRIVATE = libpq libpgtypes
 
 all: all-lib
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 145e3e8776d22e639151446ca20f857c3aa79eb0..18d9b85b83b8463e05fb875d85d50085a372bdbf 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -74,7 +74,7 @@ else
 SHLIB_LINK += $(filter -lcrypt -ldes -lcom_err -lcrypto -lk5crypto -lkrb5 -lgssapi32 -lssl -lsocket -lnsl -lresolv -lintl $(PTHREAD_LIBS), $(LIBS)) $(LDAP_LIBS_FE)
 endif
 ifeq ($(PORTNAME), win32)
-SHLIB_LINK += -lshfolder -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
+SHLIB_LINK += -lshell32 -lws2_32 -lsecur32 $(filter -leay32 -lssleay32 -lcomerr32 -lkrb5_32, $(LIBS))
 endif
 
 SHLIB_EXPORTS = exports.txt
diff --git a/src/interfaces/libpq/win32.mak b/src/interfaces/libpq/win32.mak
index 39a0bc9e445f1a65e74703c2bc1edb56c18d4db0..1b71ebd387072bb4f59aa27592fb9f7a8cbf54b5 100644
--- a/src/interfaces/libpq/win32.mak
+++ b/src/interfaces/libpq/win32.mak
@@ -214,7 +214,7 @@ CPP_SBRS=.
 RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
 
 LINK32=link.exe
-LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib ws2_32.lib secur32.lib $(SSL_LIBS)  $(KFW_LIB) $(ADD_SECLIB) \
+LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib ws2_32.lib secur32.lib $(SSL_LIBS)  $(KFW_LIB) $(ADD_SECLIB) \
  /nologo /subsystem:windows /dll $(LOPT) /incremental:no \
  /pdb:"$(OUTDIR)\libpqdll.pdb" /machine:$(CPU) \
  /out:"$(OUTDIR)\$(OUTFILENAME).dll"\
diff --git a/src/port/path.c b/src/port/path.c
index 378920597d0e07ddbd4154030dd2cafa586b0f5e..4f2b152fdc9421be55fc406a9c1d129d2d8fc472 100644
--- a/src/port/path.c
+++ b/src/port/path.c
@@ -785,9 +785,11 @@ get_home_path(char *ret_path)
 	char	   *tmppath;
 
 	/*
-	 * Note: We use getenv here because the more modern
-	 * SHGetSpecialFolderPath() will force us to link with shell32.lib which
-	 * eats valuable desktop heap.
+	 * Note: We use getenv() here because the more modern SHGetFolderPath()
+	 * would force the backend to link with shell32.lib, which eats valuable
+	 * desktop heap.  XXX This function is used only in psql, which already
+	 * brings in shell32 via libpq.  Moving this function to its own file
+	 * would keep it out of the backend, freeing it from this concern.
 	 */
 	tmppath = getenv("APPDATA");
 	if (!tmppath)