Двойная строка с нулевым символом в конце

Мне нужно отформатировать строку так, чтобы она была двойной строкой с нулевым символом в конце, чтобы использовать SHFileOperation.

Интересно то, что я нашел одно из следующих рабочих, но не оба сразу:

  // Example 1
  CString szDir(_T("D:\\Test"));
  szDir = szDir + _T('\0') + _T('\0');

  // Example 2  
  CString szDir(_T("D:\\Test"));
  szDir = szDir + _T("\0\0");

  //Delete folder
  SHFILEOPSTRUCT fileop;
  fileop.hwnd   = NULL;    // no status display
  fileop.wFunc  = FO_DELETE;  // delete operation
  fileop.pFrom  = szDir;  // source file name as double null terminated string
  fileop.pTo    = NULL;    // no destination needed
  fileop.fFlags = FOF_NOCONFIRMATION|FOF_SILENT;  // do not prompt the user
  fileop.fAnyOperationsAborted = FALSE;
  fileop.lpszProgressTitle     = NULL;
  fileop.hNameMappings         = NULL;
  int ret = SHFileOperation(&fileop);

Кто-нибудь знает об этом?

Есть ли другой способ добавить строку с двойным завершением?

6
задан Mr_and_Mrs_D 16 March 2015 в 22:10
поделиться