使用ICMP ping 64位不能正常工作吗? [英] pinging windows 64 bit with ICMP dosn't work ?

查看:198
本文介绍了使用ICMP ping 64位不能正常工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个班级的工作非常好,有32位但是不用64位



任何人都可以帮我解决这个问题吗?





this class work excellent with 32 bit but dosn''t with 64 bit

any body can help me to fix it ?


using System;
using System.Net;
using System.Runtime.InteropServices;

namespace testPing
{
    class Class1
    {
        public static class ServerStatus
        {

            [StructLayout(LayoutKind.Sequential, Pack = 1)]
            public struct ICMP_ECHO_REPLY
            {
                public uint Address;
                public uint Status;
                public uint RoundTripTime;
                public ushort DataSize;
                public ushort Reserved;
                public IntPtr Data;
                public IP_OPTION_INFORMATION Options;
            }

            [StructLayout(LayoutKind.Sequential, Pack = 1)]
            public struct IP_OPTION_INFORMATION
            {
                public byte TTL;
                public byte TOS;
                public byte Flags;
                public byte OptionsSize;
                public IntPtr OptionsData;
                public int RealOptionData;
            }

            public static class Icmp
            {
                public const int IP_SUCCESS = 0;
                public const int IP_BUF_TOO_SMALL = 11001;
                public const int IP_REQ_TIMED_OUT = 11010;
                [DllImport("icmp.dll")]
                public static extern IntPtr IcmpCreateFile();
                [DllImport("icmp.dll")]
                public static extern uint IcmpSendEcho(IntPtr icmpHandle, uint
                ipAddr, ref int requestData, ushort requestSize, IntPtr optionInfo, ref
ICMP_ECHO_REPLY replyBuffer, uint replySize, int timeout);
                [DllImport("icmp.dll")]
                public static extern bool IcmpCloseHandle(IntPtr icmpHandle);
                public static bool Ping(string host)
                {
                    uint addr =
                    BitConverter.ToUInt32(IPAddress.Parse(host).GetAddressBytes(), 0);
                    IntPtr h = IcmpCreateFile();
                    int req = 123456789;
                    ICMP_ECHO_REPLY rep = new ICMP_ECHO_REPLY();
                    uint retval = IcmpSendEcho(h, addr, ref req, 4, IntPtr.Zero,
                    ref rep, 56, 10);
                    IcmpCloseHandle(h);
                    return (retval != 0 && rep.Status == IP_SUCCESS);
                }
            }
        }

    }
}

推荐答案

这个问题出了什么问题: http:// msdn .microsoft.com / zh-cn / library / system.net.networkinformation.ping.aspx [ ^ ]?



PS:不工作不是错误信息,也不是具体结果。

PS2:你检查过这些api调用的64位版本是否与32位系统相同?阅读本文: http://msdn.microsoft.com /en-us/library/windows/desktop/aa366050(v=vs.85).aspx [ ^ ],并寻找在64位平台上......
And what''s wrong with this one: http://msdn.microsoft.com/en-us/library/system.net.networkinformation.ping.aspx[^]?

PS: doesn''t work is not an error message, nor a concrete result.
PS2: have you checked if the 64 bit version of those api calls is the same as in 32 bit systems? Read this one: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366050(v=vs.85).aspx[^], and look for "On a 64-bit platform..."


这篇关于使用ICMP ping 64位不能正常工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆