1 #include "syshdrs.h"
2 
3 #if defined(WIN32) || defined(_WINDOWS)
4 
5 extern "C" void
6 GetSpecialDir(char *dst, size_t size, int whichDir)
7 {
8 	LPITEMIDLIST idl;
9 	LPMALLOC shl;
10 	char path[MAX_PATH + 1];
11 	HRESULT hResult;
12 
13 	memset(dst, 0, size);
14 	hResult = SHGetMalloc(&shl);
15 	if (SUCCEEDED(hResult)) {
16 		hResult = SHGetSpecialFolderLocation(
17 					NULL,
18 					CSIDL_PERSONAL,
19 					&idl
20 					);
21 
22 		if (SUCCEEDED(hResult)) {
23 			if(SHGetPathFromIDList(idl, path)) {
24 				(void) strncpy(dst, path, size - 1);
25 				dst[size - 1] = '\0';
26 			}
27 			shl->Free(idl);
28 		}
29 		shl->Release();
30 	}
31 }	// GetSpecialDir
32 
33 
34 #endif
35