資源描述:
《C++常用操作函數(shù)》由會員上傳分享,免費在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、實用文檔C++常用操作函數(shù)載入動態(tài)庫boolLoadDll(){HttpDownDll=LoadLibrary("HTTPDOWNDLL.dll");if(HttpDownDll==NULL){MessageBox(0,"載?入?動ˉ態(tài)?庫a錯洙?誤ó!?","錯洙?誤ó",MB_OK
2、MB_ICONWARNING);FreeLibrary(HttpDownDll);returnfalse;}SendCommand=(SendCommandFunc)GetProcAddress(HttpDownDll,"Send
3、Command");if(SendCommand==NULL){MessageBox(0,"GetProcAddress錯洙?誤ó!?","錯洙?誤ó",MB_OK
4、MB_ICONWARNING);FreeLibrary(HttpDownDll);returnfalse;}returntrue;}卸載動態(tài)庫boolFreeDll(){FreeLibrary(HttpDownDll);SendCommand=NULL;returntrue;}字符串分割std::vectorsplit(st
5、d::stringstr,std::stringpattern){std::string::size_typepos;std::vectorresult;str+=pattern;//擴?展1字?符?串?以?方?便?操ù作痢?intsize=str.size();for(inti=0;i6、ack(s);i=pos+pattern.size()-1;}}returnresult;}UTF8轉(zhuǎn)GBKvoidUTF8ToGBK(std::string&s){charszOut[256];memset(szOut,0,256);strcpy(szOut,s.c_str());unsignedshort*wszGbk=NULL;char*szGbk=NULL;//長度intlen=MultiByteToWideChar(CP_UTF8,0,(LPCSTR)szOut,-1,NULL,0);wszGbk=ne
7、wunsignedshort[len+1];memset(wszGbk,0,len*2+2);MultiByteToWideChar(CP_UTF8,0,(LPCSTR)szOut,-1,(LPWSTR)wszGbk,len);//長度len=WideCharToMultiByte(CP_ACP,0,(LPWSTR)wszGbk,-1,NULL,0,NULL,NULL);szGbk=newchar[len+1];memset(szGbk,0,len+1);WideCharToMultiByte(CP_ACP,0,
8、(LPWSTR)wszGbk,-1,szGbk,len,NULL,NULL);//szOut=szGbk;//這樣得到的szOut不正確,因為此句意義是將szGbk的首地址賦給szOut,//當delete[]szGbk執(zhí)行后szGbk的內(nèi)存空間將被釋放,此時將得不到szOut的內(nèi)容memset(szOut,'