Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Posts
    13

    Unanswered: How to know the name of the computer

    That is!
    Anybody knows what can I do to know de name of the computer with my access program?
    thanks

  2. #2
    Join Date
    Dec 2002
    Location
    Glasgow, UK
    Posts
    100
    this bit of code will return the computer name

    fOSMachineName()
    Access XP & WinXP Pro

  3. #3
    Join Date
    Dec 2003
    Posts
    13
    Can you give me an example to use it?
    I put it in the code and vb doesn't recognize it.
    Thank you very much.

  4. #4
    Join Date
    Sep 2003
    Location
    T.O.
    Posts
    326
    I'm not sure what library fOSMachineName() is in, but it's not in a standard one. Is this from http://www.mvps.org/access/api/api0009.htm?

    I've relied on an API call to determine the computer name. You'll need to put this in the declarations section of your code:
    Code:
    Declare Function api_GetComputerName Lib "kernel32" Alias "GetComputerNameA" _
            (ByVal lpBuffer As String, nSize As Long) As Long
    Then you can use the following to determine the computer name:
    Code:
    Function GetCompName() As Variant
        Dim strCompName As String
        Dim lngLength As Long
        Dim lngResult As Long
        ' -- SET UP THE BUFFER
        strCompName = String$(255, 0)
        lngLength = 255
        ' -- MAKE THE CALL
        lngResult = api_GetComputerName(strCompName, lngLength)
        ' -- ASSIGN THE VALUE
        GetCompName = Left(strCompName, InStr(1, strCompName, Chr(0)) - 1)
    End Function
    HTH.
    All code ADO/ADOX unless otherwise specified.
    Mike.

  5. #5
    Join Date
    Dec 2003
    Posts
    13

    THX!

    I copy the code of the link you gave me and it works!
    Thank you very much!

Posting Permissions

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