Reads the next input record.
HRESULT STDMETHODCALLTYPE ReadRecord(OUT VARIANT_BOOL *pbDataAvailable);
bDataAvailable = ReadRecord();
C++ example:
HRESULT CProcessesInputContext::ReadRecord(OUT VARIANT_BOOL *pbDataAvailable) { if( m_hSnapshot == INVALID_HANDLE_VALUE ) { // This is the first time we have been called // Get a shapshot of the current processes m_hSnapshot = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); if( m_hSnapshot == INVALID_HANDLE_VALUE ) { // Error return HRESULT_FROM_WIN32( GetLastError() ); } // Get the first entry if( !Process32First( m_hSnapshot, &m_processEntry32 ) ) { DWORD dwLastError = GetLastError(); if( dwLastError == ERROR_NO_MORE_FILES ) { // No processes *pbDataAvailable = VARIANT_FALSE; return S_OK; } else { // Error return HRESULT_FROM_WIN32( GetLastError() ); } } else { // There is data available *pbDataAvailable = VARIANT_TRUE; return S_OK; } } else { // We have already been called before, and we have already taken a snapshot // Get the next entry if( !Process32Next( m_hSnapshot, &m_processEntry32 ) ) { DWORD dwLastError = GetLastError(); if( dwLastError == ERROR_NO_MORE_FILES ) { // No more processes *pbDataAvailable = VARIANT_FALSE; return S_OK; } else { // Error return HRESULT_FROM_WIN32( GetLastError() ); } } else { // There is data available *pbDataAvailable = VARIANT_TRUE; return S_OK; } } }VBScript example:
Function ReadRecord() If m_nIndex >= UBound(m_objQFEArray) Then ' Enumeration terminated ReadRecord = False Else 'Advance m_nIndex = m_nIndex + 1 ReadRecord = True End If End Function
© 2004 Microsoft Corporation. All rights reserved.