how to get IP adress by knowing computer name...

i need to know IP adress of a computer if i know it's name on a LAN...
that's if i'm using SHBrowseForFolder with the BIF_BROWSEFORCOMPUTER flag set...then i can have the computer name...but i need the next step...get the IP adress of that computer...

thanx

Comments

  • : i need to know IP adress of a computer if i know it's name on a LAN...
    : that's if i'm using SHBrowseForFolder with the BIF_BROWSEFORCOMPUTER flag set...then i can have the computer name...but i need the next step...get the IP adress of that computer...
    :
    : thanx
    :
    :

    If you know the host name call gethostbyname. It returns you HOSTENT structure where you find IP address in dottet type. Use inet_ntoa to change it to DWORD.
  • : : i need to know IP adress of a computer if i know it's name on a LAN...
    : : that's if i'm using SHBrowseForFolder with the BIF_BROWSEFORCOMPUTER flag set...then i can have the computer name...but i need the next step...get the IP adress of that computer...
    : :
    : : thanx
    : :
    : :
    :
    : If you know the host name call gethostbyname. It returns you HOSTENT structure where you find IP address in dottet type. Use inet_ntoa to change it to DWORD.

    An easier way might be to ping it. In my experience, PING usually gives you the IP address as translated by the DNS.

    P-Sz
  • : An easier way might be to ping it. In my experience, PING usually gives you the IP address as translated by the DNS.
    :
    : P-Sz
    :

    How the hell you think you can send PING inside a program?
    Create console and somehow using pipes send ping command to it and read response from that pipe?
    Or using RAW socket to send ICMP packet? But then you would need the IP address. You planning to use RAW socket to create DNS packet?
    Or should user first open console, send ping, copy IP address from response and then paste it to program?

    Just use that gethostbyname. It does everything for you.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories