comparison libpurple/win32/win32dep.c @ 29224:3be6a18e0bcb

No need to access SHGetFolderPath() indirectly any more with required versions of Windows.
author Daniel Atallah <daniel.atallah@gmail.com>
date Sat, 31 Oct 2009 20:03:26 +0000
parents 224f9674a57e
children 10ea601e6502
comparison
equal deleted inserted replaced
29223:8d10605105f2 29224:3be6a18e0bcb
26 #include "internal.h" 26 #include "internal.h"
27 #include <winuser.h> 27 #include <winuser.h>
28 28
29 #include "debug.h" 29 #include "debug.h"
30 #include "notify.h" 30 #include "notify.h"
31
32 /*
33 * DEFINES & MACROS
34 */
35
36 /* For shfolder.dll */
37 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR);
38 typedef HRESULT (CALLBACK* LPFNSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR);
39 31
40 /* 32 /*
41 * LOCALS 33 * LOCALS
42 */ 34 */
43 static char *app_data_dir = NULL, *install_dir = NULL, 35 static char *app_data_dir = NULL, *install_dir = NULL,
113 105
114 /* Determine Purple Paths during Runtime */ 106 /* Determine Purple Paths during Runtime */
115 107
116 /* Get paths to special Windows folders. */ 108 /* Get paths to special Windows folders. */
117 gchar *wpurple_get_special_folder(int folder_type) { 109 gchar *wpurple_get_special_folder(int folder_type) {
118 static LPFNSHGETFOLDERPATHW MySHGetFolderPathW = NULL;
119 gchar *retval = NULL; 110 gchar *retval = NULL;
120 111 wchar_t utf_16_dir[MAX_PATH + 1];
121 if (!MySHGetFolderPathW) { 112
122 MySHGetFolderPathW = (LPFNSHGETFOLDERPATHW) 113 if (SUCCEEDED(SHGetFolderPathW(NULL, folder_type, NULL,
123 wpurple_find_and_loadproc("shfolder.dll", "SHGetFolderPathW"); 114 SHGFP_TYPE_CURRENT, utf_16_dir))) {
124 } 115 retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL);
125
126 if (MySHGetFolderPathW) {
127 wchar_t utf_16_dir[MAX_PATH + 1];
128
129 if (SUCCEEDED(MySHGetFolderPathW(NULL, folder_type, NULL,
130 SHGFP_TYPE_CURRENT, utf_16_dir))) {
131 retval = g_utf16_to_utf8(utf_16_dir, -1, NULL, NULL, NULL);
132 }
133 } 116 }
134 117
135 return retval; 118 return retval;
136 } 119 }
137 120