Admin Production ni-theme
Current Publication

GetCurrentUser

LabWindows/CVI

GetCurrentUser

int GetCurrentUser (char userName[], size_t bufferSize, unsigned int *actualNameSize);

Purpose

This function returns the name of the user currently logged in to the Windows operating system.

Parameters

Input
Name Type Description
bufferSize size_t The size of the buffer, in bytes, passed as the userName parameter. If you are passing NULL into that parameter, then this value is ignored.
Output
Name Type Description
userName char [] Returns the name of the currently logged–in user. This buffer must be large enough to hold the complete name. If you are unsure of the size of the name, you may safely pass NULL in this parameter –– the function will return the User Interface Library error UIEBufTooSmall and the required buffer size, in bytes, will be passed out through the actualNameSize parameter.
actualNameSize unsigned int Returns the exact size of the logged–in user's name, including the terminating NULL. The buffer you pass to the userName parameter must be at least this large (or NULL).

Return Value

Name Type Description
status int The status code that the function returns.

0 indicates success.

A negative value indicates an error.

This function may return a Programmer's Toolbox or UI Library error code. Call GetGeneralErrorString to obtain a text description of the error.

Additional Information

Library: Programmer's Toolbox

Include file: toolbox\toolbox.h

LabWindows/CVI compatibility: LabWindows/CVI 5.5 and later

Example

Refer to activex\cvi\TodoDemo.cws for an example of using the GetCurrentUser function.