Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Getting the Windows User Name Programmatically

The attached zip file contains three files: "User Name Property.vI", "User Name Property (SubVI).vi", User Name (SDK call).vi", and "sdk_project.dll". These methods are useful for programmatically obtaining user information for purposes of setting access privileges in a VI.

"User Name Property.vi and User Name Property (SubVI).vi"
These VIs are nearly identical, except that "User Name Property.vi" is a stand-alone VI and User Name Property (SubVI).vi could be used as a SubVI. They both use VI Server functions (available in LabVIEW 5.0 or higher) to retrieve the user's login name, either from the local machine or from a remote machine. The major difference is that "User Name Property.vi" terminates with a Close Application or VI Reference function, while "User Name Property (SubVI).vi" is open-ended.

NOTE 1: The VI Server user name method will not work if you build the VI into an executable. When a VI is built into an executable the user name information is stripped out to help decrease the size of the executable. If you want to get the user name in an executable you will have to use a DLL call as detailed below.

"User Name (SDK call).vi"
Calls a Windows SDK function "GetUserName" to retrieve the login name of the user from the OS. You cannot call remote machines using this VI.
"sdk_project.dll"
This file is required by the User Name (SDK call).vi. If you want to use the User Name (SDK call).vi in an executable you must put the sdk_project.dll in the same folder as built application.

NOTE 2: You must have LabVIEW 5.0 (or higher) on your development and target machine for this VI to run properly.

NOTE 3: You must have the "LabWindows/CVI Run-Time Engine" installed for this VI to run properly.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
Comments
Luca_Nitopi
Member
Member
on

No more from LV 5.

Requested LV 821

Contributors