Cstring ccallschedulingsystemdlg: getfilepath (void)
{
Hmodule module = getmodulehandle (0 );
Char pfilename [max_path];
Getmodulefilename (module, pfilename, max_path );
Cstring csfullpath (pfilename );
Int NPOs = csfullpath. reversefind (_ T ('\\'));
If (NPOs <0)
Return cstring ("");
Else
Return csfullpath. Left (NPOs );
}
Char * ccallschedulingsystemdlg: encodetoutf8 (const char * mbcsstr)
{
// The Chinese and English paths that can be played
Int wcslen;
Wchar_t * wszstring;
Int u8len;
Char * szu8;
// Pre-convert to get the size of the required space
Wcslen =: multibytetowidechar (cp_acp, null, mbcsstr, strlen (mbcsstr), null, 0 );
// Leave a space for '\ 0' to allocate space. multibytetowidechar does not give' \ 0' Space
Wszstring = new wchar_t [wcslen + 1];
// Conversion
: Multibytetowidechar (cp_acp, null, mbcsstr, strlen (mbcsstr), wszstring, wcslen );
// Add '\ 0' at the end'
Wszstring [wcslen] = '\ 0 ';
/*************************************** *********************************/
/* Unicode to utf8 */
/*************************************** *********************************/
// Unicode to utf8
// Pre-convert to get the size of the required space. The function used this time is opposite to the above name
U8len =: widechartomultibyte (cp_utf8, null, wszstring, wcslen (wszstring), null, 0, null, null );
// Same as above, the allocated space should be reserved for '\ 0'
// Although utf8 is a unicode compression format, it is also a multi-byte string, so it can be saved as char
Szu8 = new char [u8len + 1];
// Conversion
// The strlen for Unicode is wcslen.
: Widechartomultibyte (cp_utf8, null, wszstring, wcslen (wszstring), szu8, u8len, null, null );
// Add '\ 0' at the end'
Szu8 [u8len] = '\ 0 ';
Free (wszstring );
Return szu8;
}
Bool ccallschedulingsystemdlg: emptydirectory (cstring & Spath)
{
Cfilefind finder;
Cstring swildcard = Spath + "//*.*";
Bool bfound;
Bool bworking = finder. findfile (swildcard );
Bfound = bworking;
While (bworking)
{
Bworking = finder. findnextfile ();
If (finder. isdots () continue;
If (finder. isdirectory ())
{
Cstring S = finder. getfilepath ();
Emptydirectory (s );
Removedirectory (finder. getfilepath ());
Continue;
}
_ Tunlink (finder. getfilepath (); // note that _ tunlink is used here.
}
Return bfound;
}
This article from the "Know what it does not" blog, please be sure to keep this source http://shenyantao.blog.51cto.com/1957956/1543253