织梦CMS - 轻松建站从此开始!

罗索

An ATL project to run PING and TRACERT

罗索客 发布于 2003-03-27 10:01 点击:次 
This article was contributed by Fred Forester. Download Source Code and Example The Icmpcom project is a basic ALT template created by the ATL wizard. The control acts as an interface to the ICMP.DLL . This DLL is supplied by MS to allow PING and TRA
TAG:

This article was contributed by Fred Forester.

Download Source Code and Example




The Icmpcom project is a basic ALT template created by the ATL wizard. The control acts as an interface to the ICMP.DLL . This DLL is supplied by MS to allow PING and TRACERT抯 to be run under a dos window.

The Control can be used by a VB5 app to create a nice list box and series of button and edit boxes to provide a user interface to PING and TRACERT.

ICMP.DLL is impleted via a Thread which is started when the StartPing method is called. The thread continues to run till the operation finishes or is canceled via a StopPing call. Tracert is implemented automatically when a StartPing request is issued and the tracert option in the parmlist is TRUE.

The Methods should be invoked in the following order. SetPingVariables and RunPing can be called as a request is needed. When the app terminates be sure to call StopPing.

StartICMP Must be the first call made to the control. Loads and initializes the DLL returns an error message thru the event sink if failed
SetPingVariables(厖) Just That. It accepts most all of the options accepted by the Dos Ping. It can support all of them if you want to code them up.
RunPing() We can finally issue a ping request.  
StopPing() tries to cancel the operation that is in progress  
StopICMP Last call to the control. Unloads the DLL and cleans up Winsock

The Events will call into the container under 3 possible conditions.

When the Ping/Tracert request wants to send back a reply.
When the Ping/Tracert request is completed
When StopICMP is called.
PingMsgEvent(BSTR) Passes back the data returned from the request. The data is pre formatted and ready to display.  
PingDoneEvent() After each PING request is completed  
PingTerminated() After StopICMP is called  

The sample VB and MSVC++ app demonstrates how icmpcom works.

The VC++ container was a little more work than VB. The Event Sinks had to be added by creating a new class in class wizard based from CcmdTarget. The functions (sink events) had to be added to the CPP and H files manually after the class was created. Note the BEGIN_DISPATCH_MAP() section in the cpp file.

Reference materials.
Beginning ATL COM programming Wrox Press http://www.wrox.com
Active/X COM control programming Wrox Press http://www.wrox.com
The ATL samples from Visual C++ 5.0
The WorldOfATL http://www.worldofatl.com
MFC vckbase ATL Section http://www.vckbase.com
MSJ June 1998 http://www.microsoft.com/msj


Last updated: 22 June 1998 (Forester)
本站文章除注明转载外,均为本站原创或编译欢迎任何形式的转载,但请务必注明出处,尊重他人劳动,同学习共成长。转载请注明:文章转载自:罗索实验室 [http://www.rosoo.net/a/200303/733.html]
本文出处: 作者:Forester
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
将本文分享到微信
织梦二维码生成器
推荐内容