Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

To get the IP Address of Machine with Windows 95 as OS

Posted on 1999-06-30
11
Medium Priority
?
296 Views
Last Modified: 2013-12-29
Hello,

I want to get the IP Address of the machine which is
having Windows 95 as OS.  The below given code snippet
helps me to get the IP address for machines
having Windows 98 or Windows NT as OS.

Expecting your response.

Thanks in advance.

Sreenivasan N.


//code Snippet  starts here----
      WORD wVersionRequested;
      WSADATA wsaData;
      char name[255];
      char * ip;
      PHOSTENT hostinfo;
      wVersionRequested = MAKEWORD( 2, 0 );

      if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
      {

            if( gethostname ( name, sizeof(name)) == 0)
            {
                  if((hostinfo = gethostbyname(name)) != NULL)
                  {
                        ip = inet_ntoa (*(struct in_addr
*)*hostinfo->h_addr_list);

                  }
            }

            WSACleanup( );
      }
//-- ends here
0
Comment
Question by:wasan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +3
11 Comments
 
LVL 3

Expert Comment

by:knowme
ID: 1689497
Getting the IP Address of your PC with Windows 95 OS, goto START-RUN and type WINIPCFG. Make sure you have you TCP/IP included in your network settings.
0
 
LVL 3

Expert Comment

by:rjhawkin
ID: 1689498
Im not a programmer, but here are some options you might considder from a quick search of MSDN online you might want to subscribe. Its free and moderatly usefull. a bit of poking arround retrieved the following ideas. most of which came from http://support.microsoft.com/support/kb/articles/Q81/2/46.ASP

OPTION #1:
Unfortunately, the GetPerAdapterInfo is only enabled in windows 2000: (http://msdn.microsoft.com/library/sdkdoc/rras/tcpip_2pyn.htm)

OPTION #2:
If the machine uses a static IP you can request it from the folowing registry entry.
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Class\NetTrans\0005\
       Value:  IPAddress   data: 0.0.0.0


OPTION #3:
For Windows 95 Support for Net Function Calls  check http://support.microsoft.com/support/kb/articles/Q125/7/00.ASP 

OPTION #4:
Perform a winsock request to SYSTEM/WINSOCK32n.DLL.  The name of the function is inet_addr and the ordinal is 0009. if you want the other names's quick view the file.

OPTION #5:
This is an annoying parse the file method but it might be a more dependable kludge.

WINIPCFG /Batch <outfile> /all

<outfile> will contain the below plus all of the information that the winipcfg (windows version has). That way you can parse the file for the information you need.

WINIPCFG /Batch <outfile>
OUTPUT:

Memphis IP Configuration

0 Ethernet adapter :

      IP Address. . . . . . . . . : 127.0.0.1
      Subnet Mask . . . . . . . . : 255.255.255.0
      Default Gateway . . . . . . : 127.0.0.5



0
 

Author Comment

by:wasan
ID: 1689499
As most of the options mentioned above have already been tried and we need more specific function call or comments.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 13

Expert Comment

by:gonzal13
ID: 1689500
Why not call the ISP provider. That is what they are for, to help you.
0
 

Author Comment

by:wasan
ID: 1689501
Actually we need to get the IP Address of the System through our Program, as it is being used for another process.  

So, at run time we need to know the Client's Machine's IP Address.

Internet Service Provider will not help us in this regard.

However thanks for your Response.
0
 
LVL 3

Expert Comment

by:rjhawkin
ID: 1689502
Is DHCP being used to deciminate the IP currently in these systems? or do you need to be able to determine the IP of a given system reguardless of what ISP in particular the machine is connected to?
0
 
LVL 2

Expert Comment

by:RebosMan
ID: 1689503
So ... you're trying to re-invent a DNS call or ???
0
 
LVL 3

Expert Comment

by:rjhawkin
ID: 1689504
He is searching for a programmed system call to use on a Windows 95 system that returns the IP address of of the current machine. Reguardless of how the IP was assigned,
ie: WINS/DHCP/BOOTP/or manual entered.

Well there is a way that just occured to me. It would be annoying, and generate traffic, but you could create a connection to a known machine on the internet that returns the IP as a response to a query.

It would require setting up a machine, to perform the check, return the IP information, and disconnect. The connect could be performed via TCP or UDP. I know unix has that capability, or software could be written for windows.

It wouldnt work across proxies or, firewalls (unless a special port execption was created).

0
 
LVL 2

Expert Comment

by:RebosMan
ID: 1689505
And making a HTTP call to have the user's machine run out to a web site and make a cookie to pass back to the client machine would be to messy and inaccurate ? Unless you kindly ask microsoft for the code for their winipcfg program, I don't think you're going to find a valid answer to this one ...
0
 
LVL 3

Expert Comment

by:rjhawkin
ID: 1689506
Fortunatly there is more to the internet than HTTP. You can set up a linux box to reject connections execpt from specific machines, display a banner and then to disconnect. The banner can contain the connecting IP. You can set this up for any port on the system. Port 23(telnet/TCP) or even Port 21 (FTPd/UDP).

It would concievably be possible to write a windows program to do this as well. and simply make a setting in the orriginal application as to the IP address of the machine it should check for the IP lookup. As I said before it is plainly a kludge.

Im not a programmer. Im not exactly sure of the method used to set up the system this way, but I know it is possible. eg below is a connection log from a system setup as such. If this is a viable solution for WASAN then I just need to ask the admin of the system how difficult it was to setup.

[This system is running Linux version 2.2.1]
:~> ftp 127.1
Connected to 127.1.
220-######################################################
220-
220-Sorry, rjhawkin@127.0.0.1,
220-
220-You are not allowed to connect.
220-
220-######################################################
421 Service not available, remote server has closed connection

0
 
LVL 15

Accepted Solution

by:
simonet earned 100 total points
ID: 1689507
Change the line:

      wVersionRequested = MAKEWORD( 2, 0 );

to

      wVersionRequested = MAKEWORD( 1, 1 );

This works for me under Windows 95. I have a very, *very* similar code to yours. Requesting V1.1 of the DLLs did the trick for me.

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article helps those who get the 0xc004d307 error when trying to rearm (reset the license) Office 2013 in a Virtual Desktop Infrastructure (VDI) and/or those trying to prep the master image for Microsoft Key Management (KMS) activation. (i.e.- C…
In this modest contribution, I want to share with the IT community (especially system administrators, IT Support Engineers and IT Help Desks) about Windows crashes/hangs and how to deal with these particular problems.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question