Skip to content

Commit 889f038

Browse files
committed
Use SHGetFolderPath instead of SHGetSpecialFolderPath to find the
APPDATA directory on Windows. Magnus Hagander
1 parent c0e0d3e commit 889f038

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

src/Makefile.global.in

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*-makefile-*-
2-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.208 2004/12/19 02:16:18 momjian Exp $
2+
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.209 2005/01/26 19:23:59 tgl Exp $
33

44
#------------------------------------------------------------------------------
55
# All PostgreSQL makefiles include this file and use the variables it sets,
@@ -384,9 +384,10 @@ override LDFLAGS := -L$(top_builddir)/src/port $(LDFLAGS)
384384
endif
385385
endif
386386

387-
# to make ws2_32.lib the last library
387+
# to make ws2_32.lib the last library, and always link with shfolder,
388+
# so SHGetFolderName isn't picked up from shell32.dll
388389
ifeq ($(PORTNAME),win32)
389-
LIBS += -lws2_32
390+
LIBS += -lws2_32 -lshfolder
390391
endif
391392

392393
# Not really standard libc functions, used by the backend.

src/bin/psql/win32.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ CPP_SBRS=.
7979

8080
LINK32=link.exe
8181
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
82-
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
82+
advapi32.lib shfolder.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
8383
odbccp32.lib wsock32.lib /nologo /subsystem:console /incremental:no\
8484
/pdb:"$(OUTDIR)\psql.pdb" /machine:I386 $(LOPT) /out:"$(OUTDIR)\psql.exe"
8585
LINK32_OBJS= \

src/interfaces/ecpg/ecpglib/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1994, Regents of the University of California
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.30 2005/01/18 05:00:17 momjian Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/ecpglib/Makefile,v 1.31 2005/01/26 19:24:01 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -30,6 +30,11 @@ OBJS= execute.o typename.o descriptor.o data.o error.o prepare.o memory.o \
3030
SHLIB_LINK = -L../pgtypeslib -lpgtypes $(libpq) \
3131
$(filter -lintl -lssl -lcrypto -lkrb5 -lcrypt -lm, $(LIBS)) $(PTHREAD_LIBS)
3232

33+
ifeq ($(PORTNAME), win32)
34+
# Link to shfolder.dll instead of shell32.dll
35+
SHLIB_LINK += -lshfolder
36+
endif
37+
3338
all: all-lib
3439

3540
# Shared library stuff

src/interfaces/libpq/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.127 2005/01/18 05:00:30 momjian Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.128 2005/01/26 19:24:02 tgl Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -55,7 +55,7 @@ endif
5555
# matter.)
5656
SHLIB_LINK += $(filter -lcrypt -ldes -lkrb -lcom_err -lcrypto -lk5crypto -lkrb5 -lssl -lsocket -lnsl -lresolv -lintl, $(LIBS)) $(PTHREAD_LIBS)
5757
ifeq ($(PORTNAME), win32)
58-
SHLIB_LINK += -lwsock32 -lws2_32 -lshell32 $(filter -leay32 -lssleay32, $(LIBS))
58+
SHLIB_LINK += -lshfolder -lwsock32 -lws2_32 $(filter -leay32 -lssleay32, $(LIBS))
5959
endif
6060

6161

src/interfaces/libpq/fe-connect.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.301 2005/01/14 00:25:56 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.302 2005/01/26 19:24:02 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -38,7 +38,7 @@
3838
#ifdef _WIN32_IE
3939
#undef _WIN32_IE
4040
#endif
41-
#define _WIN32_IE 0x0400
41+
#define _WIN32_IE 0x0500
4242
#ifdef near
4343
#undef near
4444
#endif
@@ -3296,7 +3296,7 @@ pqGetHomeDirectory(char *buf, int bufsize)
32963296
char tmppath[MAX_PATH];
32973297

32983298
ZeroMemory(tmppath, sizeof(tmppath));
3299-
if (!SHGetSpecialFolderPath(NULL, tmppath, CSIDL_APPDATA, FALSE))
3299+
if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, tmppath) != S_OK)
33003300
return false;
33013301
snprintf(buf, bufsize, "%s/postgresql", tmppath);
33023302
return true;

src/interfaces/libpq/win32.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ LIB32_OBJS= \
138138
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\libpq.res"
139139

140140
LINK32=link.exe
141-
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shell32.lib wsock32.lib $(SSL_LIBS) \
141+
LINK32_FLAGS=kernel32.lib user32.lib advapi32.lib shfolder.lib wsock32.lib $(SSL_LIBS) \
142142
/nologo /subsystem:windows /dll $(LOPT) /incremental:no\
143143
/pdb:"$(OUTDIR)\libpqdll.pdb" /machine:I386 /out:"$(OUTDIR)\$(OUTFILENAME).dll"\
144144
/implib:"$(OUTDIR)\$(OUTFILENAME)dll.lib" /def:$(OUTFILENAME)dll.def

src/port/path.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/port/path.c,v 1.50 2005/01/10 00:19:51 tgl Exp $
11+
* $PostgreSQL: pgsql/src/port/path.c,v 1.51 2005/01/26 19:24:03 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -21,7 +21,7 @@
2121
#ifdef _WIN32_IE
2222
#undef _WIN32_IE
2323
#endif
24-
#define _WIN32_IE 0x0400
24+
#define _WIN32_IE 0x0500
2525
#ifdef near
2626
#undef near
2727
#endif
@@ -476,7 +476,7 @@ get_home_path(char *ret_path)
476476
char tmppath[MAX_PATH];
477477

478478
ZeroMemory(tmppath, sizeof(tmppath));
479-
if (!SHGetSpecialFolderPath(NULL, tmppath, CSIDL_APPDATA, FALSE))
479+
if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, tmppath) != S_OK)
480480
return false;
481481
snprintf(ret_path, MAXPGPATH, "%s/postgresql", tmppath);
482482
return true;

0 commit comments

Comments
 (0)