In MFC, File exist check and delete the file, example source code.

If file exist then delete the file, example source code in MFC

< github code >

MFC Encode / Decode example souce code

WtoC function code is here

And refer to GetMacAddress code

Encode code


Decode code


Unicode CString convert to char *

The returned char * will need to be freed after use.

< gist code start >

< gist code end >

wchar_t, WtoC, WideCharToMultiByte, WideCharToMultiByte

useful site for CString converting


Get Mac Address in MFC

GetMacAddress in MFC

Get by using GetAdaptersInfo function

Get by using ip address
//If localhost -> GetMacAddress(_T("*"));
//if have ip -> GetMacAddress(_T(""));//



CString to string

string CstringToString(CString str)
    CT2CA pszConvertedAnsiString(str);
    std::string s(pszConvertedAnsiString);

    return s;