在debug版本下处理就没错
release版本下就有错误...   - -#
BOOL CXml::Create(CString strFilePath,CString sRootName)
{
if(!IsFileExist(strFilePath))
{
HANDLE h_xmlFile;

h_xmlFile = CreateFile(strFilePath, GENERIC_WRITE, 0, NULL, CREATE_NEW, 0, 0);
if (h_xmlFile == INVALID_HANDLE_VALUE) {
XTrace(_T("Create File %s Error"), strFilePath);
return FALSE;
}
SetFilePointer(h_xmlFile,0,0,FILE_BEGIN);
char *xBuf=(char*)malloc(40*sizeof(char));
memcpy(xBuf,"<?xml version=\"1.0\" encoding=\"utf-8\"?>",sizeof("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"));
DWORD numWritten;
if (!WriteFile(h_xmlFile,xBuf,strlen(xBuf),&numWritten,0)||numWritten!=strlen(xBuf)) {
DeleteFile(strFilePath);
CloseHandle(h_xmlFile);
XTrace(_T("Write xml header Error"));
return FALSE;
}

CString sRoot;
sRoot.Format(_T("<%s>"),sRootName);

if (!WriteFile(h_xmlFile,sRoot,sRoot.GetLength(),&numWritten,0)||numWritten!=sRoot.GetLength()) {
DeleteFile(strFilePath);
CloseHandle(h_xmlFile);
XTrace(_T("Write xml root start Error"));
return FALSE;
}

sRoot.Format(_T("</%s>"),sRootName);
if (!WriteFile(h_xmlFile,sRoot,sRoot.GetLength(),&numWritten,0)||numWritten!=sRoot.GetLength()) {
DeleteFile(strFilePath);
CloseHandle(h_xmlFile);
XTrace(_T("Write xml root end Error"));
return FALSE;
}

CloseHandle(h_xmlFile);
}
else
XTrace(_T("File %s Already Exist"), strFilePath);
return TRUE;
}