|
From: Paul on 8 May 2008 10:51 I have encountered this issue: http://support.microsoft.com/kb/154608 (In my case, reverse DNS is not configured, so getnameinfo returns an IP address and gethostbyaddr, a NetBIOS name prefixed with IS~.) Obviously I could remove IS~ and perhaps that would be it, for I am aware of this table: http://support.microsoft.com/kb/q163409/ but I thought I could give it a try and take it a little further than gethostbyaddr does: obtain a name table for the required host and find not just the first unique name but a proper machine one. Using NetBIOS API, I got as far as displaying name tables for hosts and MAC addresses of adapters whose NetBIOS name I know but I cannot think of a way of getting a NetBIOS name from an IP address. Could you put me in the right direction? Thank you. Paul
From: "Charles Wang [MSFT]" on 9 May 2008 01:20 Hi Paul, I understand that you would like to know how to get a NetBIOS name from an IP address by using NetBIOS API. If I have misunderstood, please let me know. From my research, you can use NetBIOS API to retrieve host names and MAC addresses of the network adapters, however to retrieve NetBIOS name from an IP address, you need to use the WinSock API gethostbyaddr instead of NetBIOS API. From this article, http://msdn.microsoft.com/en-us/library/ms738521(VS.85).aspx, we can also find the following descriptions: "Developers requiring NetBIOS name resolution may need to use gethostbyaddr until their applications are completely independent of NetBIOS names." You can retrieve the Netbios name from an IP address with the following code: ============================== unsigned long res; WSADATA wsaData; HOSTENT* pHost; res = inet_addr(ip); if ((res == INADDR_NONE) || (res == 0)) { strcpy(host, "unable to resolve"); return false; } if (WSAStartup(MAKEWORD(1, 1), &wsaData)) { strcpy(host, "unable to resolve"); return false; } pHost = gethostbyaddr((char*)&res, sizeof(res), AF_NETBIOS); if (pHost == NULL) { MessageBox("unable to resolve"); return false; } MessageBox(pHost->h_name); WSACleanup(); ================================= Also I do not recommend that you use NetBios API since Netbios is not available for use on Windows Vista, Windows Server 2008, and subsequent versions of the operating system. You can find the clarification in this article: Netbios Function http://msdn.microsoft.com/en-us/library/bb870903(VS.85).aspx If you want to get Network parameters information, I would recommend that you use IP Helper functions and Winsock functions such as GetAdaptersInfo and gethostbyaddr. You may also refer to this article for more information: Review of the network adapter parameters http://www.codeproject.com/KB/IP/bsipconfig.aspx Hope this helps. If you have any other questions or concerns, please feel free to let me know. Have a nice day! Best regards, Charles Wang Microsoft Online Community Support =========================================================== Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg(a)microsoft.com. =========================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ============================================================ This posting is provided "AS IS" with no warranties, and confers no rights. =========================================================
From: "Charles Wang [MSFT]" on 9 May 2008 01:30 Hi Paul, I notice that you have posted the same question in our microsoft.public.win32.programmer.networksnewsgroup, which I have also already responded. So please check my answer there and if you need any further assistance on this particular issue, please reply to me in that thread so I can follow up with you in time. Best regards, Charles Wang Microsoft Online Community Support ========================================================= Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg(a)microsoft.com. ========================================================= This posting is provided "AS IS" with no warranties, and confers no rights. =========================================================
|
Pages: 1 Prev: (VC++ 6.0) Strange single step behavior Next: does vstudio 2005 run perfectly on vista? |