Solved

Knowing my UserId in NT3.51, and VBA (Excel 5.0)

Posted on 1998-09-08
4
142 Views
Last Modified: 2010-04-30
Is there any API in Windows NT 3.51 I could use with VB for Applocations (Excel 5.0), that let me know my User Id (and much better other data from the user, like my user name)?
If there exists (I'm sure there must exist), please write an example of use, or be as detailed as possible, as I am not experienced with Windows APIs
0
Comment
Question by:mquiles
  • 3
4 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1433569
Here are funtion you can use :

' *** Get computer and user information
Private Declare Function GetComputerNameA Lib "kernel32" (ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long


Public Function GetUserName() As String
   ' *** Get the user name
   
   Dim UserName         As String * 255

   Call GetUserNameA(UserName, 255)
   GetUserName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)

End Function

Public Function GetComputerName() As String
   ' *** Get the computer name
   
   Dim UserName         As String * 255

   Call GetComputerNameA(UserName, 255)
   GetComputerName = Left$(UserName, InStr(UserName, Chr$(0)) - 1)

End Function

0
 
LVL 14

Expert Comment

by:waty
ID: 1433570
You can go on my web site, you will find more source file for you to do what you want.

see my profile for web site
0
 

Author Comment

by:mquiles
ID: 1433571
Thanks a lot, it's very helpful for me, and works perfectly, as I wanted.
0
 
LVL 14

Expert Comment

by:waty
ID: 1433572
Don't hesitate to post me other questions
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now