Results 1 to 2 of 2

Thread: Extract Windows Info

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2001
    Location
    RI
    Posts
    1

    Cool Extract Windows Info

    I need help with a simple VB program.

    I need it to look at the computers user info and get the machine's name and windows OEM number.

    Then save that info to a simple ascII file in the same directory this program is in.

    Can anyone help?

    John

  2. #2
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    Code:
    Private Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Private Sub Form_Load()
        Dim strString As String
        'Create a buffer
        strString = String(255, Chr$(0))
        'Get the computer name
        GetComputerName strString, 255
        'remove the unnecessary chr$(0)'s
        strString = Left$(strString, InStr(1, strString, Chr$(0)) - 1)
        'Show the computer name
        MsgBox strString
    End Sub
    
    Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
    Private Sub Form_Load()
        Dim strTemp As String, strUserName As String
        'Create a buffer
        strTemp = String(100, Chr$(0))
        'Get the temporary path
        GetTempPath 100, strTemp
        'strip the rest of the buffer
        strTemp = Left$(strTemp, InStr(strTemp, Chr$(0)) - 1)
    
        'Create a buffer
        strUserName = String(100, Chr$(0))
        'Get the username
        GetUserName strUserName, 100
        'strip the rest of the buffer
        strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
    
        MsgBox "Hello " + strUserName 
    End Sub
    For Window OEM, try SysInfo object in VB.

    Regards.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width