#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    38
    Rep Power
    12

    Is there any way to get the name of the computer in C++.


    I need to obtain the local computers name for a C++ program I am converting from VB. This is how the VB program did it.

    Set WN = CreateObject("Wscript.Network")

    transfilename = WN.ComputerName
    outfilename = WinPath & transfilename

    Is there any way C++ can do this? All I need is the computers name.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    38
    Rep Power
    12
    Never mind I figured it out.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    Bulgaria
    Posts
    22
    Rep Power
    0

    Re: Is there any way to get the name of the computer in C++.


    Originally posted by jwolfe
    I need to obtain the local computers name for a C++ program I am converting from VB. This is how the VB program did it.

    Set WN = CreateObject("Wscript.Network")

    transfilename = WN.ComputerName
    outfilename = WinPath & transfilename

    Is there any way C++ can do this? All I need is the computers name.
    Of course, what you do in VB is just a wrapper of the Windows API which is written in C. There is all you need in the API. In fact VB can't do things that the API can't do. VB is just a wrapper, So there is such a function and it is very simple:

    GetComputerName(lpszName,pSize);

    Example:

    TCHAR szName[MAX_PATH];
    DWORD dwSize = MAX_COMPUTERNAME_LENGTH+1;

    GetComputerName(szName,&dwSize);

IMN logo majestic logo threadwatch logo seochat tools logo