當前位置: 首頁>>代碼示例>>C++>>正文


C++ CompareString函數代碼示例

本文整理匯總了C++中CompareString函數的典型用法代碼示例。如果您正苦於以下問題:C++ CompareString函數的具體用法?C++ CompareString怎麽用?C++ CompareString使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了CompareString函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: DSEnumProc

BOOL CALLBACK DSEnumProc(LPGUID lpGUID, LPCTSTR lpszDesc, LPCTSTR lpszDrvName, LPVOID lpContext)
{
	LPGUID* pGUID = (LPGUID*)lpContext;

	if (pGUID == NULL) {
		return FALSE;
	}
	if ((*pGUID) != NULL) {
		return TRUE;
	}

	if (lpGUID != NULL) {
		// XP, 2k
	    if ((CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDrvName, -1, TEXT("cmipci.sys"), -1) == CSTR_EQUAL) &&
		  (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("CMI8738/8768 Wave"), -1) == CSTR_EQUAL)) {
			(*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
			memcpy((*pGUID), lpGUID, sizeof(GUID));
			return TRUE;
		}
		// Vista
		if (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, lpszDesc, -1, TEXT("Speakers (CMI8738/8768 Audio Device)"), -1) == CSTR_EQUAL) {
			(*pGUID) = (LPGUID)LocalAlloc(LPTR, sizeof(GUID));
			memcpy((*pGUID), lpGUID, sizeof(GUID));
			return TRUE;
		}
	}
	return TRUE;
}
開發者ID:hoangduit,項目名稱:reactos,代碼行數:28,代碼來源:main.cpp

示例2: FilenameCompare

int FilenameCompare( const TCHAR * pa, const TCHAR * pb )
{
	int diff = CompareString( LOCALE_USER_DEFAULT, NORM_IGNORECASE|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH, pa, -1, pb, -1 );
	if ( diff == CSTR_EQUAL )
		diff = CompareString( LOCALE_USER_DEFAULT, SORT_STRINGSORT, pa, -1, pb, -1 );
	return diff - CSTR_EQUAL;
}
開發者ID:caidongyun,項目名稱:libs,代碼行數:7,代碼來源:ListView.cpp

示例3: int

long CDistDatabaseReactor::SelectRowId(int& nRowId,const char* strCadLyName,const char *strSdeLyName,int nIndex,AcDbDatabase* pDB)
{
	int nResult = 0;
	DIST_STRUCT_CHANGEROWID* pTemp = m_pRowIdData;

	int nID = int(pDB);
	nRowId = -1;

	while(pTemp != NULL)
	{
		if(nID == pTemp->nID && CompareString(strCadLyName,pTemp->strCadLyName)==0
			                 && CompareString(strSdeLyName,pTemp->strSdeLyName)==0)
		{
			int nCount = pTemp->RowIdArray.GetSize();
			if(nIndex>=0 && nIndex < nCount)
			{
				nRowId = pTemp->RowIdArray.GetAt(nIndex);
				nResult = 1;
			}
			break;
		}
		pTemp = pTemp->pNext;
	}

	return nResult;
}
開發者ID:fredrikjonsson,項目名稱:cadof72bian,代碼行數:26,代碼來源:DistDatabaseReactor.cpp

示例4: BootUpModule

void BootUpModule(void) {
	typedef enum {
		Bootup1, Passed, Error
	} BootUpState_Type;
	BootUpState_Type BootUpState = Bootup1;

	while (BootUpState != Passed) {
		switch (BootUpState) {

		case Bootup1:
			SendSim900("AT+Bootup\r\n");

			if (CompareString(buffer, "OK", 2)) {	//are the same
				FRTOS1_xSemaphoreGive(SuccessLedMutex);
				BootUpState = Passed;
			}
			break;

		default:
			BootUpState = Error;
			break;

		}
		FRTOS1_vTaskDelay(BOOTUP_STATEMACHINE_DELAY_MS/portTICK_PERIOD_MS);
	}
}
開發者ID:tghaefli,項目名稱:stingray,代碼行數:26,代碼來源:SIM900.c

示例5: CompareNoCase

int FarString::CompareNoCase (const char * Str, size_t nLength) const
{
  if (nLength > fData->fLength+1)
    nLength = fData->fLength+1;
  return 2-CompareString (LOCALE_USER_DEFAULT, NORM_IGNORECASE, fData->fText, nLength,
    Str, nLength);
}
開發者ID:Maximus5,項目名稱:evil-programmers,代碼行數:7,代碼來源:FARString.cpp

示例6: CompareListItem

static int CALLBACK CompareListItem(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	int cmp = CompareString((LCID)lParamSort, 0, ((LANGPACK_INFO*)lParam1)->szLanguage, -1, ((LANGPACK_INFO*)lParam2)->szLanguage, -1);
	if (cmp != 0)
		cmp -= 2;
	return cmp;
}
開發者ID:0xmono,項目名稱:miranda-ng,代碼行數:7,代碼來源:options.cpp

示例7: main

int main() {
	Student stus[] = {{"a",10},{"b",50},{"c",20}};
	for(Student* s=stus;s!=stus+3;++s){
		std::cout<<s->name<<" "<<s->score<<"\n";
	}
	Student *end = stus + sizeof(stus)/sizeof(stus[0]);
	Student *best = bestStudent(stus,end,&compareStudentScore);
	std::cout<<(*best).name<<"~~~~~~~~~~~"<<(*best).score<<std::endl;
	
	int num[] = {1,2,4,6,8,2,4};
	
	int *nEnd = num + sizeof(num)/sizeof(num[0]);
	{
		int *high = bestStudent(num,nEnd,&compareInt);
		std::cout<<*high<<std::endl;
	}
	
	{
	Compare2 comp;
	comp(3,6);
	int *high = bestStudent(num,nEnd,comp);
	std::cout<<*high<<std::endl;
	}
	
	const char* strs[]={"dsifewnrfsdfawoewaf","1654sdaf","w3rewasa3","29ajfdsof93"};
	
	const char **last = strs + sizeof(strs)/sizeof(strs[0]);
	std::sort(strs,last,CompareString());
	for(int i=0;i<4;i++) {
		std::cout<<strs[i]<<std::endl;
	}
	
	
	return 0;
}
開發者ID:amberyang,項目名稱:exercise,代碼行數:35,代碼來源:011302.cpp

示例8: HRESULT_exception

_Use_decl_annotations_
DX9_exception::DX9_exception(HRESULT hr, const char* file_name, int line) noexcept : HRESULT_exception(hr, file_name, line)
{
    try
    {
        WCHAR wide_error_string[1024];
        PCWSTR dx_message = DXGetErrorStringW(m_hr);
        if(CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, dx_message, -1, TEXT("Unknown"), -1) == CSTR_EQUAL)
        {
            assert(!"DX error string could not be found.  Was check_hr intended?");
            dx_message = L"Unknown error.";
        }

        StringCchPrintfW(wide_error_string, ARRAYSIZE(wide_error_string), L"Error: %08x: %s", m_hr, dx_message);

        const auto error_string = PortableRuntime::utf8_from_utf16(wide_error_string);
        PortableRuntime::dprintf("!%s(%d): %s\n", file_name, line, error_string.c_str());

        // Just save off the message now, but do the full formatting in what(), to allow exception unwind to free up some resources.
        m_what = std::make_shared<std::string>(std::move(error_string));
    }
    catch(const std::bad_alloc& ex)
    {
        (void)ex;       // Unreferenced parameter.

        PortableRuntime::dprintf("!Failed creation of exception object.\n");
    }
}
開發者ID:AceRoqs,項目名稱:3DDemo,代碼行數:28,代碼來源:CheckDX9.cpp

示例9: GetConnection

void GetConnection(void) {
	typedef enum {
		GetCon1, Passed, Error
	} GetConState_Type;
	GetConState_Type GetConState = GetCon1;

	while (GetConState != Passed) {
		switch (GetConState) {

		case GetCon1:
			SendSim900("AT+GetConnection\r\n");

			if (CompareString(buffer, "ok", 2)) {	//are the same
				FRTOS1_xSemaphoreGive(SuccessLedMutex);
				GetConState = Passed;
			}
			break;

		default:
			GetConState = Error;
			break;

		}
		FRTOS1_vTaskDelay(
				GET_CONNECTION_STATEMACHINE_DELAY_MS/portTICK_PERIOD_MS);
	}
}
開發者ID:tghaefli,項目名稱:stingray,代碼行數:27,代碼來源:SIM900.c

示例10: getDeviceInfo

BOOL getDeviceInfo(const GUID* category, CMIDEV* pDev)
{
	TCHAR  szServiceName[128];
	int    nIndex = 0;

	pDev->Info = SetupDiGetClassDevs(category, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
	if (pDev->Info == INVALID_HANDLE_VALUE) {
		PrintLastError("SetupDiGetClassDevs()");
		return FALSE;
	}

	pDev->InfoData.cbSize = sizeof(SP_DEVINFO_DATA);

	while (SetupDiEnumDeviceInfo(pDev->Info, nIndex, &(pDev->InfoData))) {
		if (!SetupDiGetDeviceRegistryProperty(pDev->Info, &(pDev->InfoData), SPDRP_SERVICE, NULL, (PBYTE)szServiceName, sizeof(szServiceName), NULL)) {
			PrintLastError("SetupDiGetDeviceRegistryProperty()");
			SetupDiDestroyDeviceInfoList(pDev->Info);
	    	pDev->Info = NULL;
			return FALSE;
		}

		if (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, szServiceName, -1, TEXT("cmipci"), -1) == CSTR_EQUAL) {
			return TRUE;
		}
		nIndex++;
	}

	SetupDiDestroyDeviceInfoList(pDev->Info);
	pDev->Info = NULL;
	return FALSE;
}
開發者ID:hoangduit,項目名稱:reactos,代碼行數:31,代碼來源:main.cpp

示例11: _mbsnbicoll

int _RTLENTRY _EXPFUNC _mbsnbicoll( const unsigned char *__S1, const unsigned char *__S2, size_t n )
{
    int ret;

    ret = CompareString ( __locale->handle, NORM_IGNORECASE, (LPCTSTR)__S1, n, (LPCTSTR)__S2, n );
    return (ret-2);
}
開發者ID:Mephistophil,項目名稱:linked_list,代碼行數:7,代碼來源:mbsnbico.c

示例12: findWaveDeviceID

UINT findWaveDeviceID()
{
	WAVEOUTCAPS  woc;
	UINT         i, numDev;

	numDev = waveOutGetNumDevs();
	for (i=0;i<numDev;i++) {
	    if (!waveOutGetDevCaps(i, &woc, sizeof(WAVEOUTCAPS))) {
			if ((CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("CMI8738/8768 Wave"), -1) == CSTR_EQUAL) ||
			    (CompareString(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), NORM_IGNORECASE, woc.szPname, -1, TEXT("Speakers (CMI8738/8768 Audio De"), -1) == CSTR_EQUAL)) {
				return i;
			}
    	}
	}
	return WAVE_MAPPER;
}
開發者ID:hoangduit,項目名稱:reactos,代碼行數:16,代碼來源:main.cpp

示例13: GetIDsOfNames

STDMETHODIMP CImpIDispatch::GetIDsOfNames(
            /* [in] */ REFIID riid,
            /* [size_is][in] */ OLECHAR** rgszNames,
            /* [in] */ UINT cNames,
            /* [in] */ LCID lcid,
            /* [size_is][out] */ DISPID* rgDispId)
{
	HRESULT hr;
	UINT	i;

	// Assume some degree of success
	hr = NOERROR;

	// Hardcoded mapping for this sample
	// A more usual procedure would be to use a TypeInfo
	for ( i=0; i < cNames; i++)
	{
		if (  2 == CompareString( lcid, NORM_IGNOREWIDTH, (wchar_t*)pszExtend, 3, (wchar_t*)rgszNames[i], 3 ) )
		{
			rgDispId[i] = DISPID_Extend;
		}
		else
		{
			// One or more are unknown so set the return code accordingly
			hr = ResultFromScode(DISP_E_UNKNOWNNAME);
			rgDispId[i] = DISPID_UNKNOWN;
		}
	}
	return hr;
}
開發者ID:assafyariv,項目名稱:PSG,代碼行數:30,代碼來源:idispimp.cpp

示例14: LGetSelectedCellCommon

static Boolean LGetSelectedCellCommon(ListHandle listH, Cell *listCell, GetListCellTextProcType getCellText,
														Boolean first)
	/*	This function finds the alphabetically first or last cell (depending
		on the value of first) in the currently selected cells of the list.  It
		returns false if there are no selected cells.
	*/
{
	Boolean result;
	Str255 cellText;
	Str255 bestText;
	SInt16 indexOfBestText;

	assert(getCellText != NULL);

	// Establish some pre-conditions.

	result = false;
	listCell->h = 0;
	listCell->v = 0;
	indexOfBestText = 0;
	if (first) {
		bestText[0] = 0;
		bestText[1] = 255;
		bestText[2] = 255;
	} else {
		bestText[0] = 0;
	}
	
	// Loop through the selected cells, looking for the best text (ie the
	// alphabetically first or last).

	while ( LGetSelect(true, listCell, listH) ) {
		result = true;
		getCellText(listH, listCell, cellText);
		if ( (first && (CompareString(cellText, bestText, NULL) < 0)) ||
					(!first && (CompareString(cellText, bestText, NULL) > 0)) )  {
			indexOfBestText = listCell->v;
			BlockMoveData(cellText, bestText, cellText[0] + 1);
		}
		listCell->v += 1;
	}
	
	// Finish up.
	listCell->h = 0;
	listCell->v = indexOfBestText;
	return result;
}
開發者ID:fruitsamples,項目名稱:MoreIsBetter,代碼行數:47,代碼來源:MoreLists.c

示例15: cliCompareContacts

int cliCompareContacts(const ClcContact *contact1, const ClcContact *contact2)
{
	ClcCacheEntry *c1 = contact1->pce, *c2 = contact2->pce;

	for (int i = 0; i < _countof(g_CluiData.bSortByOrder); i++) {
		BYTE &by = g_CluiData.bSortByOrder[i];

		if (by == SORTBY_STATUS) { //status
			int ordera = GetStatusModeOrdering(c1->getStatus());
			int orderb = GetStatusModeOrdering(c2->getStatus());
			if (ordera == orderb)
				continue;
			return ordera - orderb;
		}

		// one is offline: offline goes below online
		if (!g_CluiData.fSortNoOfflineBottom) {
			int statusa = c1->getStatus();
			int statusb = c2->getStatus();
			if ((statusa == ID_STATUS_OFFLINE) != (statusb == ID_STATUS_OFFLINE))
				return 2 * (statusa == ID_STATUS_OFFLINE) - 1;
		}

		int r = 0;

		switch (by) {
		case SORTBY_NAME: // name
			r = mir_wstrcmpi(contact1->szText, contact2->szText);
			break;

		case SORTBY_NAME_LOCALE: // name
			if (LocaleId == -1)
				LocaleId = Langpack_GetDefaultLocale();
			r = CompareString(LocaleId, NORM_IGNORECASE, SAFETSTRING(contact1->szText), -1, SAFETSTRING(contact2->szText), -1) - 2;
			break;

		case SORTBY_LASTMSG: // last message
			r = (int)CompareContacts2_getLMTime(contact2->hContact) - (int)CompareContacts2_getLMTime(contact1->hContact);
			break;

		case SORTBY_PROTO:
			if (contact1->proto == nullptr || contact2->proto == nullptr)
				continue;
			r = GetProtoIndex(contact1->proto) - GetProtoIndex(contact2->proto);
			break;

		case SORTBY_RATE:
			r = contact2->bContactRate - contact1->bContactRate; // reverse order 
			break;

		default: // should never happen
			continue;
		}

		if (r != 0)
			return r;
	}
	return 0;
}
開發者ID:tweimer,項目名稱:miranda-ng,代碼行數:59,代碼來源:modern_contact.cpp


注:本文中的CompareString函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。