// ---------------- // Global routines // ---------------- KString GetOCRResult(const TValueArray<BYTE, true>& ImageBuffer) { const KString FileName = g_StartUpGlobals.m_StartFolder + TEMP_FOLDERAME + KGUIDToString(CreateGUID()) + TEXT(".bmp"); TFile File(FileName, FOF_BINARYWRITE); File.Write(ImageBuffer.GetDataPtr(), ImageBuffer.GetN()); File.m_bRemoveOnRelease = true; File.Close(); char* pBuffer = (char*)calloc(32768, 1); SAFE_BLOCK_BEGIN { g_pGetString(FileName, pBuffer); } SAFE_BLOCK_END KString Result = pBuffer; free(pBuffer); return Result; }
CString GetGUID( CString sLocation )//WinLib { CString str,csResult; csResult = CreateGUID(); return csResult; //sContentID = Guid.NewGuid() }
//--------------------------------------------------------------------------- void __fastcall TForm8::BtnRandomClick(TObject *Sender) { TGUID LGuid; CreateGUID(LGuid); UnicodeString LStrGuid = GUIDToString(LGuid); EdtBeaconUUID->Text = LStrGuid.SubString0(1, LStrGuid.Length() - 2); EdtBeaconMajor->Text = IntToStr(Random(USHRT_MAX)); EdtBeaconMinor->Text = IntToStr(Random(USHRT_MAX)); }
Event CreateCustomEvent() { Event event; event.id = CreateGUID(); event.date = GetDate(); event.time = GetTime(); event.p0 = rand(); event.p1 = rand(); event.p2 = rand(); return event; }
// pData:COMPLEX_MSG_DATA* void CPackageManage::CreateGroupMsg(int groupid, BYTE grouptype, LPVOID pData) { MSG_PKG_INFO info = {0}; info.dwMsgSeq = InterlockedIncrement(&g_nMsgSeq); char guid[GUID_SIZE] = {0}; CreateGUID(guid); memcpy(info.guid, guid, GUID_SIZE); info.nRoomID = groupid; info.ucRoomType = grouptype; info.nSendCount = 0; info.ucFormat = eMsgFormat_Def; info.lpData = pData; m_vtMsgPkg.push_back(info); SendGroup(guid); }
void DeamonModule::Init() { ReadConfig(); m_config.set_local_port(Config::GetInstance().GetLocalServerPort()); for(std::vector<std::string>::iterator it = m_trustedModules.begin(); it != m_trustedModules.end(); it++) { m_config.add_trusted_modules(*it); } for(std::vector<std::string>::iterator it = m_pluginPaths.begin(); it != m_pluginPaths.end(); it++) { Plugin* plugin = m_config.add_plugins(); plugin->set_path(*it); } strcpy(m_userPassword.m_user, CreateGUID().c_str()); strcpy(m_userPassword.m_pass, CreateGUID().c_str()); Twainet::SetUsersList(m_module, &m_userPassword, 1); int port = Config::GetInstance().GetLocalServerPort(); Twainet::CreateServer(m_module, port, Twainet::IPV4, true); }
std::string RandString(int size) { std::string GUID = CreateGUID(); size_t charN = 0; char erazeChars[] = {'{', '}', '-'}; while(charN < 3) { size_t pos = GUID.find(erazeChars[charN]); if(pos == -1) { charN++; continue; } GUID.erase(pos, 1); } return size < (int)GUID.size() ? std::string(GUID.begin(), GUID.begin() + size) : GUID; }
// pData:COMPLEX_MSG_DATA* void CPackageManage::CreateMsg(LPCTSTR userid, LPVOID pData, BYTE ucFormat/* =eMsgFormat_Def */, BYTE ucType/* =eMsgSend_Normal */, LPCTSTR pszInnerID/* =_T("") */, int nPublicID/* =-1 */, int nRouteID/* =-1 */) { MSG_PKG_INFO info = {0}; info.dwMsgSeq = InterlockedIncrement(&g_nMsgSeq);; char guid[GUID_SIZE] = {0}; CreateGUID(guid); memcpy(info.guid, guid, GUID_SIZE); COPY_USERID(info.userid, userid); info.ucRoomType = eCR_None; info.ucMsgType = ucType; COPY_USERID(info.szInnerID, pszInnerID); info.nPublicID = nPublicID; info.nRouteID = nRouteID; info.nSendCount = 0; info.ucFormat = ucFormat; info.lpData = pData; m_vtMsgPkg.push_back(info); SendMsgPkg(guid); }
CString GetAlbumGUID(CString csAlbum,int PLAYER_TYPE, TContentMap* inMap,bool* bAdded) { CString csContentID = _T(""); TContentMap::iterator p; // Show key for(p = inMap->begin(); p!=inMap->end(); ++p) { if(p->second->Source == PLAYER_TYPE && PathMatchSpec(p->second->Album,csAlbum)) { csContentID = p->second->UID; *bAdded = true; break; } } if(!*bAdded) { csContentID = CreateGUID(); } return csContentID; }