Double null-terminated string

Posted by wengseng on Stack Overflow See other posts from Stack Overflow or by wengseng
Published on 2011-01-06T02:28:15Z Indexed on 2011/01/06 5:53 UTC
Read the original article Hit count: 228

Filed under:
|
|

I need to format a string to be double null-terminated string in order to use SHFileOperation.

Interesting part is i found one of the following working, but not both:

  // 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);

Does anyone has idea on this?
Is there other way to append double-terminated string?

© Stack Overflow or respective owner

Related posts about c++

Related posts about string