Get IP address of computer (MFC/VC++)
-
Hi, Could you provide me a code snippet on how to acquire the IP address of the computer? I'm not using .NET just a pure visual c++ IDE. I just want to get the ip address of my computer and store it in a string. If you could give me an idea on how to do that without using the .NET environment, I'd really appreciate it very much.:-O Thanks, Christina J.
-
Hi, Could you provide me a code snippet on how to acquire the IP address of the computer? I'm not using .NET just a pure visual c++ IDE. I just want to get the ip address of my computer and store it in a string. If you could give me an idea on how to do that without using the .NET environment, I'd really appreciate it very much.:-O Thanks, Christina J.
-
Hi, Could you provide me a code snippet on how to acquire the IP address of the computer? I'm not using .NET just a pure visual c++ IDE. I just want to get the ip address of my computer and store it in a string. If you could give me an idea on how to do that without using the .NET environment, I'd really appreciate it very much.:-O Thanks, Christina J.
Hi, IS this what yoo are looking for?
struct hostent \*Host; SIZE\_T t=100; CString szIP , szName; char \*host\_name = new char\[100\]; gethostname(host\_name,t); Host = gethostbyname(host\_name); szName = host\_name; szIP = inet\_ntoa(\*((struct in\_addr\*)Host->h\_addr)); delete \[\]host\_name;
Regards, Eli