大问题是这样的~

B.B 2001-12-25 09:37:51
问题是这样的。现在想用NET MONRITOR提供的SDK里面NPP的接口IRTC来实现实时的监控IP包。
在微软的MSDN里面有关于这个接口的详细的描述。

现在已经创建好这个COM接口了。但是,在使用这个接口里面的Connect函数连接到NIC的时候遇见了
麻烦。因为Connect这个函数需要用户提供2个Callback函数。但是根本没有这两个函数的具体描述
和用途。按照它定义中的名字看来,应该是用来通知用户状态的改变和提交新帧给用户。而且这些所
有细节都应该是随着这两个callback函数的参数提供给用户的。所以这两个callback函数的参数定
义就非常的重要但是,非常可惜的是微软并没有提供给我们具体如何去定义这两个函数,也没有现成
的例子,我用的SDK是Platform SDK Feb 2001的。不知道是不是和这个SDK有关系。

另外,下面是附带的MSDN里面关于这个函数的说明。关于callback函数部分都给出了注解。

另外,微软的这个sdk文档里面也是漏洞百出。许多需要包含的头文件的名字都是错误的。比如文档里
面的finder.h应该是nmfinder.h才对。

Platform SDK: Network Monitor
IRTC::Connect
The Connect method connects the NPP to the network by using a specified
NIC and provides configuration information for the connection.

HRESULT STDMETHODCALLTYPE Connect(
HBLOB hInputBlob,
LPVOID StatusCallbackProc, // Callback 函数1
LPVOID FramesCallbackProc, // Callback 函数2
LPVOID UserContext, // Callback 函数的参数之一,是用户传递的一个参数
HBLOB hErrorBlob // 返回的错误描述
);

Parameters

hInputBlob
[in] Handle to the BLOB that specifies the NIC that you are connecting to and the configuration information for that connection.
StatusCallbackProc
[in] Address of the user's status callback function, which receives status updates such as triggers. This parameter can be set to NULL.
FramesCallbackProc
[in] Address of the user's frame callback function, which is used to receive status updates such as triggers. This parameter can be set to NULL.
UserContext
[in] Value passed when the user's status and frame callback function is called. If both callback functions are specified, they must use the same user-context value. The value of this parameter is typically either HWND or a 'this' pointer.
hErrorBlob
[out] Handle to an error BLOB that contains additional error information. See Remarks at the bottom of this topic for information about what is in the error BLOB.

Return Values
If this method is successful, the return value is NMERR_SUCCESS.

If the method is unsuccessful, the return value is an error code.

Error Codes
Error codes returned by the Connect method include those errors returned by the internal IRTC::Configure call.

NMERR_ALREADY_CONNECTED
This instance of the NPP COM object is already connected to the network.
NMERR_BLOB_CONVERSION_ERROR
The configuration BLOB is corrupt. This error is generated by the IRTC::Configure call.
NMERR_BLOB_ENTRY_DOES_NOT_EXIST
The input BLOB specified by the hInputBlob parameter lacks an entry needed to perform this operation. This error may be generated by the IRTC::Connect or IRTC::Configure call. Look at the error BLOB returned by hErrorBlob to determine which entry was not found.
NMERR_BLOB_NOT_INITIALIZED
The CreateBlob function has not been called. This error is generated by the IRTC::Configure call.
NMERR_BLOB_STRING_INVALID
The string is not null-terminated. This error is generated by the IRTC::Configure call.
NMERR_ILLEGAL_TRIGGER
The trigger portion of the input BLOB is corrupt. This error is generated by the IRTC::Configure call.
NMERR_INVALID_BLOB
The object specified in hInputBlob is not a BLOB. This error is generated by the IRTC::Configure call.
NMERR_OUT_OF_MEMORY
The memory needed to perform this operation is unavailable. This error is generated by the IRTC::Configure call.
NMERR_TIMEOUT
The request has timed out. This error is generated by the IRTC::Configure call.
NMERR_UPLEVEL_BLOB
The version number of the BLOB specified in hInputBlob is incorrect. This error is generated by the IRTC::Configure call.


Remarks 备注

When the Connect method is called, the NPP automatically calls the IRTC::Configure
method by using the BLOB provided by hInputBlob. Note that any error codes
returned by the call to IRTC::Configure are passed back and returned by the
IRTC::Connect call.

This method must be called before you can start capturing frames. Note that when
you connect to the network using this method, you must continue to use the IRTC
interface to capture frames.

When calling this function, you must specify a status or frame callback function,
even if it only acts as a placeholder. // 当你调用这个函数的时候,你至少要指定状态或则
新帧回调函数其中之一

The input BLOB specified by hInputBlob can be obtained by calling the
GetNPPBlobFromUI, GetNPPBlobTable, and SelectNPPBlobFromTable methods.

The error BLOB returned in hErrorBlob contains error information that the developer
or the application can use for troubleshooting. The error BLOB returned by hErrorBlob contains entries that Network Monitor could not understand or find in the input BLOB specified in hInputBlob. For example, if NMERR_BLOB_ENTRY_DOES_NOT_EXIST is returned, the entry Network Monitor could not find is included in the returned error BLOB.

For information about See
Obtaining the input BLOB that represents a NIC Selecting a Network Interface Card


Requirements
Windows NT/2000: Requires Windows NT 4.0 or later.
Version: Requires Network Monitor 2.0.
Header: Declared in IRTC.h.

See Also
IRTC::Configure, IRTC::Disconnect, IRTC::Start

Built on Thursday, May 11, 2000
...全文
77 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
howard 2001-12-25
  • 打赏
  • 举报
回复
http://www.csdn.net/expert/topic/434/434283.shtm

各位高人,请帮忙看一下,如能解决,必500分相送
是关于网络文件传输的问题

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧