本文整理汇总了C++中COUNT_OF函数的典型用法代码示例。如果您正苦于以下问题:C++ COUNT_OF函数的具体用法?C++ COUNT_OF怎么用?C++ COUNT_OF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了COUNT_OF函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InsertNode
HTREEITEM InsertNode(HWND hwndTV, HTREEITEM hItem, LPWSTR name)
{
WCHAR buf[MAX_NEW_KEY_LEN];
HTREEITEM hNewItem = 0;
TVITEMEXW item;
if (!hItem) hItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CARET, 0);
if (!hItem) return FALSE;
if (SendMessageW(hwndTV, TVM_GETITEMSTATE, (WPARAM)hItem, TVIS_EXPANDEDONCE) & TVIS_EXPANDEDONCE) {
hNewItem = AddEntryToTree(hwndTV, hItem, name, 0, 0);
} else {
item.mask = TVIF_CHILDREN | TVIF_HANDLE;
item.hItem = hItem;
if (!TreeView_GetItemW(hwndTV, &item)) return FALSE;
item.cChildren = 1;
if (!TreeView_SetItemW(hwndTV, &item)) return FALSE;
}
SendMessageW(hwndTV, TVM_EXPAND, TVE_EXPAND, (LPARAM)hItem );
if (!hNewItem) {
for(hNewItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_CHILD, (LPARAM)hItem); hNewItem;
hNewItem = (HTREEITEM)SendMessageW(hwndTV, TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)hNewItem)) {
item.mask = TVIF_HANDLE | TVIF_TEXT;
item.hItem = hNewItem;
item.pszText = buf;
item.cchTextMax = COUNT_OF(buf);
if (!TreeView_GetItemW(hwndTV, &item)) continue;
if (lstrcmpW(name, item.pszText) == 0) break;
}
}
if (hNewItem)
SendMessageW(hwndTV, TVM_SELECTITEM, TVGN_CARET, (LPARAM)hNewItem);
return hNewItem;
}
示例2: UPDOWN_GetBuddyInt
/***********************************************************************
* UPDOWN_GetBuddyInt
* Tries to read the pos from the buddy window and if it succeeds,
* it stores it in the control's CurVal
* returns:
* TRUE - if it read the integer from the buddy successfully
* FALSE - if an error occurred
*/
static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr)
{
WCHAR txt[20], sep, *src, *dst;
int newVal;
if (!((infoPtr->Flags & FLAG_BUDDYINT) && IsWindow(infoPtr->Buddy)))
return FALSE;
/*if the buddy is a list window, we must set curr index */
if (UPDOWN_IsBuddyListbox(infoPtr)) {
newVal = SendMessageW(infoPtr->Buddy, LB_GETCARETINDEX, 0, 0);
if(newVal < 0) return FALSE;
} else {
/* we have a regular window, so will get the text */
/* note that a zero-length string is a legitimate value for 'txt',
* and ought to result in a successful conversion to '0'. */
if (GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt)) < 0)
return FALSE;
sep = UPDOWN_GetThousandSep();
/* now get rid of the separators */
for(src = dst = txt; *src; src++)
if(*src != sep) *dst++ = *src;
*dst = 0;
/* try to convert the number and validate it */
newVal = strtolW(txt, &src, infoPtr->Base);
if(*src || !UPDOWN_InBounds (infoPtr, newVal)) return FALSE;
}
TRACE("new value(%d) from buddy (old=%d)\n", newVal, infoPtr->CurVal);
infoPtr->CurVal = newVal;
return TRUE;
}
示例3: main
/*
* Main Loop
*/
int main()
{
LOG("--------------------------------\r\n");
/* Unmask interrupt for output compare match A on TC0 */
timers_setup_timer(TIMER_COUNTER0, TIMER_MODE_CTC, 1000UL);
TIMSK0 |= (1 << OCIE0A);
lcd_load_custom_character(degree_symbol, CUSTOM_SYMBOL_DEGREE);
cli_init();
motor_init(&g_timers_state);
log_init();
scheduler_init(&g_timers_state, g_tasks, COUNT_OF(g_tasks));
interpolator_init(&g_timers_state);
sei();
log_start();
/* Main Loop: Run Tasks scheduled by scheduler */
while (1) {
int i;
for (i = 0; i < 50; i++) {
serial_check(); /* needs to be called frequently */
}
scheduler_service();
}
}
示例4: InitOpenFileName
static BOOL InitOpenFileName(HWND hWnd, OPENFILENAME* pofn)
{
FILTERPAIR FilterPairs[4];
static WCHAR Filter[1024];
memset(pofn, 0, sizeof(OPENFILENAME));
pofn->lStructSize = sizeof(OPENFILENAME);
pofn->hwndOwner = hWnd;
pofn->hInstance = hInst;
/* create filter string */
FilterPairs[0].DisplayID = IDS_FLT_REGFILES;
FilterPairs[0].FilterID = IDS_FLT_REGFILES_FLT;
FilterPairs[1].DisplayID = IDS_FLT_HIVFILES;
FilterPairs[1].FilterID = IDS_FLT_HIVFILES_FLT;
FilterPairs[2].DisplayID = IDS_FLT_REGEDIT4;
FilterPairs[2].FilterID = IDS_FLT_REGEDIT4_FLT;
FilterPairs[3].DisplayID = IDS_FLT_ALLFILES;
FilterPairs[3].FilterID = IDS_FLT_ALLFILES_FLT;
BuildFilterStrings(Filter, FilterPairs, COUNT_OF(FilterPairs));
pofn->lpstrFilter = Filter;
pofn->lpstrFile = FileNameBuffer;
pofn->nMaxFile = _MAX_PATH;
pofn->lpstrFileTitle = FileTitleBuffer;
pofn->nMaxFileTitle = _MAX_PATH;
pofn->Flags = OFN_HIDEREADONLY;
pofn->lpstrDefExt = L"reg";
return TRUE;
}
示例5: CopyKeyName
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName)
{
BOOL bClipboardOpened = FALSE;
BOOL bSuccess = FALSE;
WCHAR szBuffer[512];
HGLOBAL hGlobal;
LPWSTR s;
if (!OpenClipboard(hWnd))
goto done;
bClipboardOpened = TRUE;
if (!EmptyClipboard())
goto done;
if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName))
goto done;
hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR));
if (!hGlobal)
goto done;
s = GlobalLock(hGlobal);
wcscpy(s, szBuffer);
GlobalUnlock(hGlobal);
SetClipboardData(CF_UNICODETEXT, hGlobal);
bSuccess = TRUE;
done:
if (bClipboardOpened)
CloseClipboard();
return bSuccess;
}
示例6: showstatus
void showstatus(FILE *f, struct guest_thread *vm_thread)
{
struct vm_trapframe *vm_tf = &(vm_thread->uthread.u_ctx.tf.vm_tf);
int shutdown = vm_tf->tf_exit_reason;
char *when = shutdown & VMX_EXIT_REASONS_FAILED_VMENTRY ? "entry" : "exit";
shutdown &= ~VMX_EXIT_REASONS_FAILED_VMENTRY;
char *reason = "UNKNOWN";
if (shutdown < COUNT_OF(vmxexit) && vmxexit[shutdown])
reason = vmxexit[shutdown];
fprintf(f, "Shutdown: core %d, %s due to %s(0x%x); ret code 0x%x\n",
vm_tf->tf_guest_pcoreid, when, reason, shutdown,
vm_tf->tf_exit_reason);
fprintf(f, " gva %p gpa %p cr3 %p\n", (void *)vm_tf->tf_guest_va,
(void *)vm_tf->tf_guest_pa, (void *)vm_tf->tf_cr3);
fprintf(f, " rax 0x%016lx\n", vm_tf->tf_rax);
fprintf(f, " rbx 0x%016lx\n", vm_tf->tf_rbx);
fprintf(f, " rcx 0x%016lx\n", vm_tf->tf_rcx);
fprintf(f, " rdx 0x%016lx\n", vm_tf->tf_rdx);
fprintf(f, " rbp 0x%016lx\n", vm_tf->tf_rbp);
fprintf(f, " rsi 0x%016lx\n", vm_tf->tf_rsi);
fprintf(f, " rdi 0x%016lx\n", vm_tf->tf_rdi);
fprintf(f, " r8 0x%016lx\n", vm_tf->tf_r8);
fprintf(f, " r9 0x%016lx\n", vm_tf->tf_r9);
fprintf(f, " r10 0x%016lx\n", vm_tf->tf_r10);
fprintf(f, " r11 0x%016lx\n", vm_tf->tf_r11);
fprintf(f, " r12 0x%016lx\n", vm_tf->tf_r12);
fprintf(f, " r13 0x%016lx\n", vm_tf->tf_r13);
fprintf(f, " r14 0x%016lx\n", vm_tf->tf_r14);
fprintf(f, " r15 0x%016lx\n", vm_tf->tf_r15);
}
示例7: UnloadHive
static BOOL UnloadHive(HWND hWnd)
{
WCHAR Caption[128];
LPCWSTR pszKeyPath;
HKEY hRootKey;
LONG regUnloadResult;
/* get the item key to unload */
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
/* load and set the caption and flags for dialog */
LoadStringW(hInst, IDS_UNLOAD_HIVE, Caption, COUNT_OF(Caption));
/* Enable the 'restore' privilege, unload the hive, disable the privilege */
EnablePrivilege(SE_RESTORE_NAME, NULL, TRUE);
regUnloadResult = RegUnLoadKeyW(hRootKey, pszKeyPath);
EnablePrivilege(SE_RESTORE_NAME, NULL, FALSE);
if(regUnloadResult == ERROR_SUCCESS)
{
/* refresh tree and list views */
RefreshTreeView(g_pChildWnd->hTreeWnd);
pszKeyPath = GetItemPath(g_pChildWnd->hTreeWnd, 0, &hRootKey);
RefreshListView(g_pChildWnd->hListWnd, hRootKey, pszKeyPath);
}
else
{
ErrorMessageBox(hWnd, Caption, regUnloadResult);
return FALSE;
}
return TRUE;
}
示例8: toencounter
void toencounter(DW o) {
if (encounterList.n >= COUNT_OF(encounterList.x)) {
DLOG("encounter list overflow: %i",encounterList.n);
crash();
} else {
encounterList.x[encounterList.n++] = o;
}
}
示例9: WinEventTimeToString
/* Format Timestamp from EventLog */
WCHAR * WinEventTimeToString(ULONGLONG ulongTime)
{
SYSTEMTIME sysTime;
FILETIME fTime, lfTime;
ULARGE_INTEGER ulargeTime;
struct tm tm_struct;
WCHAR result[17] = L"";
static WCHAR formatted_result[] = L"Mmm dd hh:mm:ss";
memset(&tm_struct, 0, sizeof(tm_struct));
/* Convert from ULONGLONG to usable FILETIME value */
ulargeTime.QuadPart = ulongTime;
fTime.dwLowDateTime = ulargeTime.LowPart;
fTime.dwHighDateTime = ulargeTime.HighPart;
/* Adjust time value to reflect current timezone */
/* then convert to a SYSTEMTIME */
if (FileTimeToLocalFileTime(&fTime, &lfTime) == 0) {
Log(LOG_ERROR|LOG_SYS,"Error formatting event time to local time");
return NULL;
}
if (FileTimeToSystemTime(&lfTime, &sysTime) == 0) {
Log(LOG_ERROR|LOG_SYS,"Error formatting event time to system time");
return NULL;
}
/* Convert SYSTEMTIME to tm */
tm_struct.tm_year = sysTime.wYear - 1900;
tm_struct.tm_mon = sysTime.wMonth - 1;
tm_struct.tm_mday = sysTime.wDay;
tm_struct.tm_hour = sysTime.wHour;
tm_struct.tm_wday = sysTime.wDayOfWeek;
tm_struct.tm_min = sysTime.wMinute;
tm_struct.tm_sec = sysTime.wSecond;
/* Format timestamp string */
wcsftime(result, COUNT_OF(result), L"%b %d %H:%M:%S", &tm_struct);
if (result[4] == L'0') /* Replace leading zero with a space for */
result[4] = L' '; /* single digit days so we comply with the RFC */
wcsncpy_s(formatted_result, COUNT_OF(L"Mmm dd hh:mm:ss"), result, _TRUNCATE);
return formatted_result;
}
示例10: create_child_with_stdfds
/* Creates a child process for exe, and shares the parent's standard FDs (stdin,
* stdout, stderr) with the child. Returns the child's PID on success, -1 o/w.
*/
pid_t create_child_with_stdfds(const char *exe, int argc, char *const argv[],
char *const envp[])
{
struct childfdmap fd_dups[3] = { {0, 0}, {1, 1}, {2, 2} };
pid_t kid;
int ret;
kid = create_child(exe, argc, argv, envp);
if (kid < 0)
return -1;
ret = syscall(SYS_dup_fds_to, kid, fd_dups, COUNT_OF(fd_dups));
if (ret != COUNT_OF(fd_dups)) {
sys_proc_destroy(kid, -1);
return -1;
}
return kid;
}
示例11: toDeviceId
DeviceId toDeviceId(DeviceIndex device) {
if (device < 0 || (unsigned)device > COUNT_OF(deviceTable)) {
errno = EINVAL;
return -1;
}
return deviceTable[device]->id;
}
示例12: InitializeRemoteRegistryPicker
static HRESULT
InitializeRemoteRegistryPicker(OUT IDsObjectPicker **pDsObjectPicker)
{
HRESULT hRet;
*pDsObjectPicker = NULL;
hRet = CoCreateInstance(&CLSID_DsObjectPicker,
NULL,
CLSCTX_INPROC_SERVER,
&IID_IDsObjectPicker,
(LPVOID*)pDsObjectPicker);
if (SUCCEEDED(hRet))
{
DSOP_INIT_INFO InitInfo;
static DSOP_SCOPE_INIT_INFO Scopes[] =
{
{
sizeof(DSOP_SCOPE_INIT_INFO),
DSOP_SCOPE_TYPE_USER_ENTERED_UPLEVEL_SCOPE | DSOP_SCOPE_TYPE_USER_ENTERED_DOWNLEVEL_SCOPE |
DSOP_SCOPE_TYPE_GLOBAL_CATALOG | DSOP_SCOPE_TYPE_EXTERNAL_UPLEVEL_DOMAIN |
DSOP_SCOPE_TYPE_EXTERNAL_DOWNLEVEL_DOMAIN | DSOP_SCOPE_TYPE_WORKGROUP |
DSOP_SCOPE_TYPE_UPLEVEL_JOINED_DOMAIN | DSOP_SCOPE_TYPE_DOWNLEVEL_JOINED_DOMAIN,
0,
{
{
DSOP_FILTER_COMPUTERS,
0,
0
},
DSOP_DOWNLEVEL_FILTER_COMPUTERS
},
NULL,
NULL,
S_OK
},
};
InitInfo.cbSize = sizeof(InitInfo);
InitInfo.pwzTargetComputer = NULL;
InitInfo.cDsScopeInfos = COUNT_OF(Scopes);
InitInfo.aDsScopeInfos = Scopes;
InitInfo.flOptions = 0;
InitInfo.cAttributesToFetch = 0;
InitInfo.apwzAttributeNames = NULL;
hRet = (*pDsObjectPicker)->lpVtbl->Initialize(*pDsObjectPicker,
&InitInfo);
if (FAILED(hRet))
{
/* delete the object picker in case initialization failed! */
(*pDsObjectPicker)->lpVtbl->Release(*pDsObjectPicker);
}
}
return hRet;
}
示例13: COUNT_OF
DemuxTable::DemuxTable()
{
int i = 0;
int count = COUNT_OF(table_);
while (i++ < count)
{
table_[i].handler_ = NULL;
}
}
示例14: CreateShaders
bool CreateShaders()
{
// Load the shaders and get a linked program object
const char * srcs_color_vertex[] = { ZLGLSL_LIST_LOW_PRECISION_HEADER baseattribs_vertex_shader_src, color_vertex_shader_src };
const char * srcs_color_fragment[] = { ZLGLSL_LIST_LOW_PRECISION_HEADER baseattribs_fragment_shader_src, color_fragment_shader_src };
const char * const attr_color[] = { "a_position", "a_color" };
if (!(_COLOR_PROGRAM = CreateProgramFromVertexAndFragmentShaders(COUNT_OF(srcs_color_vertex), srcs_color_vertex, COUNT_OF(srcs_color_fragment), srcs_color_fragment, COUNT_OF(attr_color), attr_color))) return false;
COLOR_UNI_MVP = (GLuint)glGetUniformLocation(_COLOR_PROGRAM, "u_mvpMatrix");
// Load the shaders and get a linked program object
const char * const attr_texture[] = { "a_position", "a_color", "a_texcoord" };
if (!(_TEXTURE_PROGRAM = CreateProgramFromVertexAndFragmentShaders(COUNT_OF(srcs_texture_vertex), srcs_texture_vertex, COUNT_OF(srcs_texture_fragment), srcs_texture_fragment, COUNT_OF(attr_texture), attr_texture))) return false;
TEXTURE_UNI_MVP = (GLuint)glGetUniformLocation(_TEXTURE_PROGRAM, "u_mvpMatrix");
glEnableVertexAttribArrayUnbuffered(0); //0 = POSITION = always required
return true;
}
示例15: decode_codon
static int
decode_codon(char codon)
{
for (int i = 0; i < COUNT_OF(kCodonMatrix); i++) {
if (kCodonMatrix[i].code == codon)
return i;
}
return -1;
}