home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ncftp.com
/
ftp.ncftp.com.zip
/
ftp.ncftp.com
/
ncftp
/
older_versions
/
ncftp-3.2.2-src.tar.bz2
/
ncftp-3.2.2-src.tar
/
ncftp-3.2.2
/
libncftp
/
util2.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
2008-07-13
|
1KB
|
50 lines
/* util2.cpp */
#if defined(WIN32) || defined(_WINDOWS)
# define _CRT_SECURE_NO_WARNINGS 1
# pragma warning(disable : 4510) // warning C4510: 'DStr' : default constructor could not be generated
# pragma warning(disable : 4512) // warning C4512: 'DStr' : assignment operator could not be generated
# pragma warning(disable : 4610) // warning C4610: struct 'DStr' can never be instantiated - user defined constructor required
//# include "syshdrs.h"
# ifndef WINVER
# define WINVER 0x0400
# endif
# ifndef _WIN32_WINNT
# define _WIN32_WINNT 0x0400
# endif
# include <windows.h> /* includes <winsock2.h> if _WIN32_WINNT >= 0x400 */
# include <shlobj.h>
# include <process.h>
extern "C" void
GetSpecialDir(char *dst, size_t size, int whichDir)
{
LPITEMIDLIST idl;
LPMALLOC shl;
char path[MAX_PATH + 1];
HRESULT hResult;
memset(dst, 0, size);
hResult = SHGetMalloc(&shl);
if (SUCCEEDED(hResult)) {
hResult = SHGetSpecialFolderLocation(
NULL,
whichDir,
&idl
);
if (SUCCEEDED(hResult)) {
if(SHGetPathFromIDList(idl, path)) {
(void) strncpy(dst, path, size - 1);
dst[size - 1] = '\0';
}
shl->Free(idl);
}
shl->Release();
}
} // GetSpecialDir
#endif