devxlogo

Getting UserID on Windows 95 and NT

Getting UserID on Windows 95 and NT

You often want to get the user ID of the current user on the machine running Windows 95 or Windows NT.Use this simple wrapper function of an API function to do the job:

 Option ExplicitPrivate Declare Function WNetGetUserA _        Lib "mpr" (ByVal lpName As String, _        ByVal lpUserName As String, _        lpnLength As Long) As LongFunction GetUser() As String        Dim sUserNameBuff As String * 255        sUserNameBuff = Space(255)        Call WNetGetUserA(vbNullString, _                sUserNameBuff, 255&)        GetUser = Left$(sUserNameBuff, _                InStr(sUserNameBuff, _                vbNullChar) - 1)End Function
See also  Essential Measures for Safeguarding Your Digital Data
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist