Ping through the Windows SDK?  
Author Message
strutt





PostPosted: Thu Sep 22 14:07:37 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK?

I'm writing a program that needs to ping different computers on the network.
Is there a ping function in the Windows SDK somewhere? Currently I'm using
a system call to issue the ping.exe command, but I'd rather not do it this
way.

Thanks,
RussR

Visual Studio329  
 
 
Jochen





PostPosted: Thu Sep 22 14:07:37 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK? Hi RussR!
> I'm writing a program that needs to ping different computers on the network.
> Is there a ping function in the Windows SDK somewhere? Currently I'm using
> a system call to issue the ping.exe command, but I'd rather not do it this
> way.

See: IcmpSendEcho2
http://msdn.microsoft.com/library/en-us/iphlp/iphlp/icmpsendecho2.asp

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
 
RussR





PostPosted: Fri Sep 23 10:28:33 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK? Jochen,

Thanks for the reply and pointing me to this function. I'm a little
confused now because it says,
Client Requires Windows "Longhorn", Windows XP, or Windows 2000
Professional.
Server Requires Windows Server "Longhorn" or Windows Server 2003.
Header Declared in Icmpapi.h.

Library Link to Iphlpapi.lib.

DLL Requires Iphlpapi.dll on Windows Server "Longhorn", Windows Server
2003, and Windows XP. Requires Icmp.dll on Windows 2000 Server and Windows
2000 Professional.


I'm running XP Pro, and I don't have any of the files it says I need. What
do I need to install to get these files?
Thanks,
RussR


> Hi RussR!
>> I'm writing a program that needs to ping different computers on the
>> network. Is there a ping function in the Windows SDK somewhere?
>> Currently I'm using a system call to issue the ping.exe command, but I'd
>> rather not do it this way.
>
> See: IcmpSendEcho2
> http://msdn.microsoft.com/library/en-us/iphlp/iphlp/icmpsendecho2.asp
>
> --
> Greetings
> Jochen
>
> My blog about Win32 and .NET
> http://blog.kalmbachnet.de/


 
 
Igor





PostPosted: Fri Sep 23 10:39:54 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK?
> Jochen,
>
> Thanks for the reply and pointing me to this function. I'm a little
> confused now because it says,
> Client Requires Windows "Longhorn", Windows XP, or Windows 2000
> Professional.
> Server Requires Windows Server "Longhorn" or Windows Server 2003.
> Header Declared in Icmpapi.h.
>
> Library Link to Iphlpapi.lib.
>
> DLL Requires Iphlpapi.dll on Windows Server "Longhorn", Windows
> Server 2003, and Windows XP. Requires Icmp.dll on Windows 2000 Server
> and Windows 2000 Professional.
>
>
> I'm running XP Pro, and I don't have any of the files it says I need.
> What do I need to install to get these files?

Download and install the latest Platform SDK here:

http://www.microsoft.com/downloads/details.aspx?FamilyId=A55B6B43-E24F-4EA3-A93E-40C0EC4F68E5&displaylang=en

--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


 
 
Jochen





PostPosted: Fri Sep 23 12:53:38 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK? Hi RussR!

> I'm running XP Pro, and I don't have any of the files it says I need. What
> do I need to install to get these files?

The DLL is located in the \windows\system32 directory...

I recomment to use LoadLibrary/GetProcAddress to use this function;
therefor you do not need a lib/h-file (or you can install the latest
PSDK if you have VC7 or later).

--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
 
RussR





PostPosted: Thu Sep 29 09:37:06 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK? Hi Jochen,

Thanks for the info. I can confirm that the Iphlpapi.dll is in my
c:\windows\system32 folder, however I'm using Borland C++ Builder v5 to do
my development and I'm unsure of how to do a LoadLibrary/GetProcAddress to
bypass the need for the lib/.h file. Any ideas?

Thanks,
RussR



> Hi RussR!
>
>> I'm running XP Pro, and I don't have any of the files it says I need.
>> What do I need to install to get these files?
>
> The DLL is located in the \windows\system32 directory...
>
> I recomment to use LoadLibrary/GetProcAddress to use this function;
> therefor you do not need a lib/h-file (or you can install the latest PSDK
> if you have VC7 or later).
>
> --
> Greetings
> Jochen
>
> My blog about Win32 and .NET
> http://blog.kalmbachnet.de/


 
 
William





PostPosted: Sat Oct 01 23:28:32 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK?

> Thanks for the info. I can confirm that the Iphlpapi.dll is in my
> c:\windows\system32 folder, however I'm using Borland C++ Builder v5 to do
> my development and I'm unsure of how to do a LoadLibrary/GetProcAddress to
> bypass the need for the lib/.h file. Any ideas?

I haven't used the Borland development suite in quite a while but in the
days when I did they had a tool named implib which would create an import
libray from the DLL.

If you don't have the tool you _should_ be able to use the technique
described here to create one.

http://support.microsoft.com/kb/q131313/

Note that the article has an MS focus but you should be able to adapt it.

If that fails you need to pass name of the DLL to LoadLibrary() to get an
instance handle to the DLL. Then for every function in the DLL that you
need to call, you pass the instance handle and the name of the function to
GetProcAddress(). That will get you a function pointer which you use to call
the function through one level of indirection.

Regards,
Will


 
 
RussR





PostPosted: Wed Oct 05 07:55:43 CDT 2005 Top

Visual Studio C++ >> Ping through the Windows SDK? I used the Borland tool implib.exe to create an lib file from the
iphlpapi.dll. That part went smoothly. The borland help said that I need
to do this for every exported function in the dll that I used:

__declspec(dllimport) return_type func_name(parameters);

So I did this:
__declspec(dllimport) HANDLE IcmpCreateFile(void);
and this:
__declspec(dllimport) DWORD IcmpSendEcho2(
HANDLE IcmpHandle,
HANDLE Event,
FARPROC ApcRoutine,
PVOID ApcContext,
IPAddr DestinationAddress,
LPVOID RequestData,
WORD RequestSize,
PIP_OPTION_INFORMATION RequestOptions,
LPVOID ReplyBuffer,
DWORD ReplySize,
DWORD Timeout
);

However when it came time to link, I got "Unresolved external
'IcmpCreateFile' and 'IcmpSendEcho2' referenced from mycode.obj

I can't figure out what I'm doing wrong as I've listed the .lib file in the
list of libraries to include at link time.

Please help!






>> Thanks for the info. I can confirm that the Iphlpapi.dll is in my
>> c:\windows\system32 folder, however I'm using Borland C++ Builder v5 to
>> do my development and I'm unsure of how to do a
>> LoadLibrary/GetProcAddress to bypass the need for the lib/.h file. Any
>> ideas?
>
> I haven't used the Borland development suite in quite a while but in the
> days when I did they had a tool named implib which would create an import
> libray from the DLL.
>
> If you don't have the tool you _should_ be able to use the technique
> described here to create one.
>
> http://support.microsoft.com/kb/q131313/
>
> Note that the article has an MS focus but you should be able to adapt it.
>
> If that fails you need to pass name of the DLL to LoadLibrary() to get an
> instance handle to the DLL. Then for every function in the DLL that you
> need to call, you pass the instance handle and the name of the function to
> GetProcAddress(). That will get you a function pointer which you use to
> call the function through one level of indirection.
>
> Regards,
> Will
>