⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 netsearch.h

📁 用vc实现枚举网上邻居
💻 H
字号:
/////////////////////////////////////////////////////////////////////////////
// Copyright (C) 1997 by Joerg Koenig and the ADG mbH, Mannheim, Germany
// All rights reserved
//
// Distribute freely, except: don't remove my name from the source or
// documentation (don't take credit for my work), mark your changes (don't
// get me blamed for your possible bugs), don't alter or remove this
// notice.
// No warrantee of any kind, express or implied, is included with this
// software; use at your own risk, responsibility for damages (if any) to
// anyone resulting from the use of this software rests entirely with the
// user.
//
// Send bug reports, bug fixes, enhancements, requests, flames, etc., and
// I'll try to keep a version up to date.  I can be reached as follows:
//    J.Koenig@adg.de                 (company site)
//    Joerg.Koenig@rhein-neckar.de    (private site)
/////////////////////////////////////////////////////////////////////////////

// last revised $Date: 3.02.98 20:27 $

#ifndef NetSearch_h
#define NetSearch_h

#include "Network.h"

template <class T>
class CNetSearch : public CNetwork {
	typedef BOOL (T::*NsFnc)(NETRESOURCE &);

	T *			m_pTheObject;
	NsFnc		m_NsFnc;

	public:		// construction
		CNetSearch() : m_pTheObject(0), m_NsFnc(0) {}

		void	Create(T * pObj, NsFnc fnc) {
					ASSERT(pObj != 0);
					ASSERT(fnc != 0);
					m_pTheObject = pObj;
					m_NsFnc = fnc;
				}

	protected:	// overridables
		virtual BOOL	OnHitResource(NETRESOURCE & rNetRC) {
							return (m_pTheObject->*m_NsFnc)(rNetRC);
						}

		virtual BOOL	NetError(DWORD dwErrorCode, LPCTSTR lpszFunction) {
							switch(dwErrorCode) {
								case ERROR_BAD_NETPATH:
								case ERROR_NO_NETWORK:
									// minor errors: continue enumeration
									return TRUE;
							}
							// serious error: break enumeration
							return CNetwork::NetError(dwErrorCode, lpszFunction);
						}
};

#endif	// NetSearch_h

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -