TrayIP is a small utility that sits in the Windows tray. If you float your mouse cursor over it will display a tooltip window with your machine's IP address(es) in it. If you right mouse button click on it a popup menu will appear. If you select any of the IP addresses it will be copied to your clipboard. If the internet (TCP/IP) is not currently available a No IP icon and message will be shown.
It's not MFC based so its memory footprint is very small (44k verses several meg). It's been tested on Windows 2000 and Windows 98 but it should work with any 32-bit version of windows.
HTTP, Zipped (17K)
FTP, Zipped (17K)
Version 0.7 -- Added a timer to automatically refresh.
Version 0.6 -- Made to work with early versions of Window95, added no IP icon, added Refresh button.
Version 0.5 -- Initial version.
If you have any comments/enhancement requests/or want to report a (*gasp*) bug please email me at support@cyberbrinedreams.com.
Overall it's a small windows program with its main window hidden. It gets the IP address(es) of the machine by getting its host entry and iterating through one if its members:
//
// List Name/IP addresses for this server
//
const int cnHostname = 1024; // should be plenty big
char szHostname[cnHostname];
string sTooltip;
gethostname( szHostname, cnHostname );
struct hostent* pHostEnt = gethostbyname( szHostname );
//
// The address(es) are in an array that is null terminated
//
int i = 0;
struct in_addr** ppAddr = 0;
for ( ppAddr = (struct in_addr**)pHostEnt->h_addr_list; *ppAddr; ppAddr++ )
{
if ( i++ != 0 ) // on second and later...
sTooltip += "\n";
sTooltip += string(inet_ntoa( **ppAddr ));
} |
// // Add icon to the shell tray area // NOTIFYICONDATA* notifydata = new NOTIFYICONDATA; notifydata->cbSize = sizeof( NOTIFYICONDATA ); notifydata->hWnd = hWnd; notifydata->uID = 0; notifydata->uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE; notifydata->uCallbackMessage = unTaskMesssage; notifydata->hIcon = LoadIcon(hInst, (LPCTSTR)IDI_TRAY_IP); strcpy( notifydata->szTip, sTooltip.c_str() ); BOOL bResult = Shell_NotifyIcon( NIM_ADD, notifydata ); |
SetWindowText( hwndText, vsIpAddresses[i].c_str() ); SendMessage( hwndText, EM_SETSEL, 0, -1 ); // select all SendMessage( hwndText, WM_COPY, 0, 0 ); // copy selected |