CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2002
    Posts
    29

    How to get server name for local machine?

    Hi,
    Is there another way other than API gethostname to get server name for local machine?
    I have to link wsock32.lib in order to use that API. Then, my app will become more fat.
    Thank you.

  2. #2
    Join Date
    Mar 2002
    Posts
    350
    you can load wsock32.dll with LoadLibrary() and then call to gethostname with GetProcAddress()

    or try getenv( "COMPUTERNAME" );

  3. #3
    Join Date
    Jun 2002
    Location
    Adelaide, South Australia
    Posts
    4
    Use the following code:

    TCHAR m_szComputerName[MAX_COMPUTERNAME_LENGTH + 1];
    DWORD dwNameSize = MAX_COMPUTERNAME_LENGTH + 1;
    ::GetComputerName (m_szComputerName, &dwNameSize);


    Works every time

  4. #4
    Join Date
    May 2002
    Posts
    29

    Yes.Use this API getComputerName().

    Yes, I use this API getComputerName(). Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured