本文整理汇总了C++中HANDLE::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ HANDLE::GetType方法的具体用法?C++ HANDLE::GetType怎么用?C++ HANDLE::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HANDLE
的用法示例。
在下文中一共展示了HANDLE::GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FindNextFile
BOOL FindNextFile(HANDLE hHandle, LPWIN32_FIND_DATA lpFindData)
{
if (lpFindData == NULL || hHandle == NULL || hHandle->GetType() != CXHandle::HND_FIND_FILE)
return FALSE;
if ((unsigned int) hHandle->m_nFindFileIterator >= hHandle->m_FindFileResults.size())
return FALSE;
CStdString strFileName = hHandle->m_FindFileResults[hHandle->m_nFindFileIterator++];
CStdString strFileNameTest = hHandle->m_FindFileDir + strFileName;
if (IsAliasShortcut(strFileNameTest))
TranslateAliasShortcut(strFileNameTest);
struct stat64 fileStat;
memset(&fileStat, 0, sizeof(fileStat));
if (stat64(strFileNameTest, &fileStat) == -1)
return FALSE;
bool bIsDir = false;
if (S_ISDIR(fileStat.st_mode))
{
bIsDir = true;
}
memset(lpFindData,0,sizeof(WIN32_FIND_DATA));
lpFindData->dwFileAttributes = FILE_ATTRIBUTE_NORMAL;
strcpy(lpFindData->cFileName, strFileName.c_str());
if (bIsDir)
lpFindData->dwFileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
if (strFileName[0] == '.')
lpFindData->dwFileAttributes |= FILE_ATTRIBUTE_HIDDEN;
if (access(strFileName, R_OK) == 0 && access(strFileName, W_OK) != 0)
lpFindData->dwFileAttributes |= FILE_ATTRIBUTE_READONLY;
TimeTToFileTime(fileStat.st_ctime, &lpFindData->ftCreationTime);
TimeTToFileTime(fileStat.st_atime, &lpFindData->ftLastAccessTime);
TimeTToFileTime(fileStat.st_mtime, &lpFindData->ftLastWriteTime);
lpFindData->nFileSizeHigh = (DWORD)(fileStat.st_size >> 32);
lpFindData->nFileSizeLow = (DWORD)fileStat.st_size;
return TRUE;
}
示例2: WaitForSingleObject
DWORD WINAPI WaitForSingleObject( HANDLE hHandle, DWORD dwMilliseconds ) {
if (hHandle == NULL || hHandle == (HANDLE)-1)
return WAIT_FAILED;
DWORD dwRet = WAIT_FAILED;
switch (hHandle->GetType()) {
case CXHandle::HND_EVENT:
case CXHandle::HND_THREAD:
SDL_mutexP(hHandle->m_hMutex);
// Perform the wait.
dwRet = WaitForEvent(hHandle, dwMilliseconds);
SDL_mutexV(hHandle->m_hMutex);
break;
case CXHandle::HND_MUTEX:
SDL_mutexP(hHandle->m_hMutex);
if (hHandle->OwningThread == pthread_self() &&
hHandle->RecursionCount > 0) {
hHandle->RecursionCount++;
dwRet = WAIT_OBJECT_0;
SDL_mutexV(hHandle->m_hMutex);
break;
}
// Perform the wait.
dwRet = WaitForEvent(hHandle, dwMilliseconds);
if (dwRet == WAIT_OBJECT_0)
{
hHandle->OwningThread = pthread_self();
hHandle->RecursionCount = 1;
}
SDL_mutexV(hHandle->m_hMutex);
break;
default:
XXLog(ERROR, "cant wait for this type of object");
}
return dwRet;
}