Solved

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

Posted on 1998-09-08
4
143 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

867 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

16 Experts available now in Live!

Get 1:1 Help Now