diff --git a/build/gmake_windows/test_opendialog.make b/build/gmake_windows/test_opendialog.make index fa247da..3a8d4c6 100644 --- a/build/gmake_windows/test_opendialog.make +++ b/build/gmake_windows/test_opendialog.make @@ -22,7 +22,7 @@ ifeq ($(config),release_x64) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += ../lib/Release/x64/nfd.lib + LIBS += ../lib/Release/x64/nfd.lib -lole32 -luuid LDDEPS += ../lib/Release/x64/nfd.lib ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -49,7 +49,7 @@ ifeq ($(config),release_x86) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += ../lib/Release/x86/nfd.lib + LIBS += ../lib/Release/x86/nfd.lib -lole32 -luuid LDDEPS += ../lib/Release/x86/nfd.lib ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -76,7 +76,7 @@ ifeq ($(config),debug_x64) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lnfd_d + LIBS += -lnfd_d -lole32 -luuid LDDEPS += ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64 LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -103,7 +103,7 @@ ifeq ($(config),debug_x86) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lnfd_d + LIBS += -lnfd_d -lole32 -luuid LDDEPS += ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32 LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) diff --git a/build/gmake_windows/test_opendialogmultiple.make b/build/gmake_windows/test_opendialogmultiple.make index bc49203..1c3b998 100644 --- a/build/gmake_windows/test_opendialogmultiple.make +++ b/build/gmake_windows/test_opendialogmultiple.make @@ -22,7 +22,7 @@ ifeq ($(config),release_x64) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += ../lib/Release/x64/nfd.lib + LIBS += ../lib/Release/x64/nfd.lib -lole32 -luuid LDDEPS += ../lib/Release/x64/nfd.lib ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -49,7 +49,7 @@ ifeq ($(config),release_x86) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += ../lib/Release/x86/nfd.lib + LIBS += ../lib/Release/x86/nfd.lib -lole32 -luuid LDDEPS += ../lib/Release/x86/nfd.lib ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -76,7 +76,7 @@ ifeq ($(config),debug_x64) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lnfd_d + LIBS += -lnfd_d -lole32 -luuid LDDEPS += ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64 LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -103,7 +103,7 @@ ifeq ($(config),debug_x86) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lnfd_d + LIBS += -lnfd_d -lole32 -luuid LDDEPS += ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32 LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) diff --git a/build/gmake_windows/test_savedialog.make b/build/gmake_windows/test_savedialog.make index 615ebc8..53df0b3 100644 --- a/build/gmake_windows/test_savedialog.make +++ b/build/gmake_windows/test_savedialog.make @@ -22,7 +22,7 @@ ifeq ($(config),release_x64) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O2 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += ../lib/Release/x64/nfd.lib + LIBS += ../lib/Release/x64/nfd.lib -lole32 -luuid LDDEPS += ../lib/Release/x64/nfd.lib ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Release/x64 -m64 -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -49,7 +49,7 @@ ifeq ($(config),release_x86) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O2 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += ../lib/Release/x86/nfd.lib + LIBS += ../lib/Release/x86/nfd.lib -lole32 -luuid LDDEPS += ../lib/Release/x86/nfd.lib ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Release/x86 -m32 -s LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -76,7 +76,7 @@ ifeq ($(config),debug_x64) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lnfd_d + LIBS += -lnfd_d -lole32 -luuid LDDEPS += ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -L../lib/Debug/x64 -m64 LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) @@ -103,7 +103,7 @@ ifeq ($(config),debug_x86) ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CFLAGS) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) - LIBS += -lnfd_d + LIBS += -lnfd_d -lole32 -luuid LDDEPS += ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -L../lib/Debug/x86 -m32 LINKCMD = $(CC) -o "$@" $(OBJECTS) $(RESOURCES) $(ALL_LDFLAGS) $(LIBS) diff --git a/build/premake5.lua b/build/premake5.lua index ab4cbed..26c3afc 100644 --- a/build/premake5.lua +++ b/build/premake5.lua @@ -101,7 +101,10 @@ local make_test = function(name) filter {"configurations:Debug", "system:linux"} linkoptions {"-lnfd_d `pkg-config --libs gtk+-3.0`"} - + + filter {"action:gmake", "system:windows"} + links {"ole32", "uuid"} + end make_test("test_opendialog") diff --git a/src/nfd_win.cpp b/src/nfd_win.cpp index b065d69..7bd95df 100644 --- a/src/nfd_win.cpp +++ b/src/nfd_win.cpp @@ -9,11 +9,15 @@ #define UNICODE #endif +#ifdef __MINGW32__ +// Explicitly setting NTDDI version, this is necessary for the MinGW compiler +#define NTDDI_VERSION NTDDI_VISTA +#define _WIN32_WINNT _WIN32_WINNT_VISTA +#endif #include #include #include -#include #include #include @@ -360,14 +364,15 @@ nfdresult_t NFD_OpenDialog( const char *filterList, HRESULT result = ::CoInitializeEx(NULL, ::COINIT_APARTMENTTHREADED | ::COINIT_DISABLE_OLE1DDE ); + + ::IFileOpenDialog *fileOpenDialog(NULL); + if ( !SUCCEEDED(result)) { NFDi_SetError("Could not initialize COM."); goto end; } - ::IFileOpenDialog *fileOpenDialog(NULL); - // Create dialog result = ::CoCreateInstance(::CLSID_FileOpenDialog, NULL, CLSCTX_ALL, ::IID_IFileOpenDialog,