本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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;
}
示例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");
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}