// #include <imagehlp.h>
// link imagehlp.lib
//
// BOOL MakeSureDirectoryPathExists(
// PCSTR DirPath
// );
//
// DirPath must end with a backslash (/) character
//
// for example:
// MakeSureDirectoryPathExists( "c://a//b// ");
例如
if (!MakeSureDirectoryPathExists("c://a//b// "))
{
LPVOID lpMsgBuf = NULL;
DWORD nlen;
nlen = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), NULL,(LPTSTR) &lpMsgBuf, 0, NULL );
if(nlen > 0)
{
log_write(" reason[%s] code[%lu]/n", lpMsgBuf, GetLastError());
LocalFree( lpMsgBuf );
}
}