From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to change the computer name use labwindows/cvi ???

I can get the computer name use function''getcomputername''.
I want to change the computer name Smiley Happy,but I havn't found the command .Can you tell me how to do it, thanks!!!
0 Kudos
Message 1 of 7
(3,893 Views)
GetComputerName is a Windows SDK function that gets the netbios name the computer takes at startup. Symmetric to it, there is SetComputerName which permits you to set the computer name, with (at least) two precautions clearly stated in the documentation:
1. The program must have administrator rights to succeed in using it
2. The computer name is changed at startup, so you will need to reboot to make this modification active.
 
To restart the computer you can use windows shutdown command this way: LaunchExecutable ("shutdown -r -f -t 0");
 
 
In case you were referring to GetCompName function found in the Programmer's toolbox, you can verify in the source code (found in <cvidir>\toolslib\toolbox) that this function relies on SDK one.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 7
(3,881 Views)
Thanks!! Let me try !!
0 Kudos
Message 3 of 7
(3,857 Views)

Smiley Happy

I found the c program,as follow

//-------------------------------------------------------------------------------------------------
// Function: GetCompName
//
// Purpose:  Retrieve the computer name and fill the user's buffer with it.  Assume the user's
//           buffer is at least MAX_COMPNAME_LEN bytes.
//
// Return:   0 for success or ToolErr/UIE error code.
//-------------------------------------------------------------------------------------------------
int CVIFUNC GetCompName (char* nameBuf)
{
    int   retVal = 0;
    DWORD bufSize;

    VERIFY_PTR_ARG(nameBuf);
    bufSize = MAX_COMPNAME_LEN;
    Assert(nameBuf);
    if (GetComputerName (nameBuf, &bufSize) == FALSE)
        retVal = ToolErr_UnknownSystemError;

Error:
    return retVal;
}

 

you mean I write a function refer to the code above or add code directly?

 

0 Kudos
Message 4 of 7
(3,854 Views)
You could take the Toolbox function as a trace to develop your own function to change the computer name. Since the precautions I mentioned nefore, you will need to pay much attention to error checking part of your routine since a detailed description of possible errors can help both you and the end user to handle problems that may arise in doing this operation.


Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 7
(3,851 Views)
> LaunchExecutable ("shutdown -r -f -t 0");
I don't think the shutdown command is part of the standard versions of
Windows, only servers, extra toolkits or cygwin.
--
Guillaume Dargaud
http://www.gdargaud.net/



0 Kudos
Message 6 of 7
(3,818 Views)

Shutdown.exe is included in standard Windows XP Professional distribution, at least in all the installations I saw till now Smiley Wink : it permits to issue a shutdown command to the local or a remote computer.

AFAIK it was originally included in W2k resource kit as a command-line command only, but it has been implemented with a graphical user interface in Win XP (possibly only from SP2).

I find it very useful and more user friendly than the ExitWindowsEx (EWX_FORCE || EWX_POWEROFF, 0); command I used prior to discover it.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 7 of 7
(3,810 Views)