Announcement

Collapse
No announcement yet.

How to get the name of the current computer ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guest's Avatar
    Guest replied
    Hi,

    Here is a piece of code I wrote "Prolly found it someplace"

    writen in PB/CC 3.04

    #COMPILE CON
    #DIM ALL
    $INCLUDE "WIN32API.INC"

    FUNCTION PBMAIN () AS LONG

    LOCAL sServer AS ASCIIZ * 256
    LOCAL sUserID AS ASCIIZ * 256
    GetUserName sUserID, 256
    GetComputerName sServer, 256
    PRINT sUserID
    PRINT sServer

    END FUNCTION


    ------------------
    Leslie Potts

    Leave a comment:


  • Karl Skergeth
    replied
    Hello Piere !

    >>> LOCAL buff AS ASCIIZ * %MAX_COMPUTERNAME_LENGTH + 1 '15 bytes + 1

    Works !

    Thank you !

    Karl

    ------------------
    Karl

    Leave a comment:


  • Pierre Bellisle
    replied
    Karl,
    try changing the following
    Code:
    LOCAL buff    AS ASCIIZ * %MAX_COMPUTERNAME_LENGTH '15 bytes
    to
    LOCAL buff    AS ASCIIZ * %MAX_COMPUTERNAME_LENGTH + 1 '15 bytes + 1
    Pierre

    Leave a comment:


  • Karl Skergeth
    replied
    Hello Jose´!

    >>> FUNCTION DS_GetComputerName () AS STRING....

    Thank you for the example.

    It works fine on Win-XP but not on Win98.
    Do i have to change the code for using with Win 98?

    Best regards
    Karl




    ------------------
    Karl

    Leave a comment:


  • Knuth Konrad
    replied
    To get José's example to work, you need to #INCLUDE "WIN32API.INC" somewhere in front of his example.

    Knuth

    ------------------
    http://www.softAware.de

    Leave a comment:


  • José Roca
    replied
    Try this one.
    Code:
    ' --------------------------------------------------------------------------
    ' Retrieves the computer name of the current system.
    ' --------------------------------------------------------------------------
    FUNCTION DS_GetComputerName () AS STRING
       LOCAL lResult AS LONG
       LOCAL buff    AS ASCIIZ * %MAX_COMPUTERNAME_LENGTH '15 bytes
       LOCAL nlen    AS DWORD
       nlen = SIZEOF(buff)
       lResult = GetComputerName(buff, nlen)
       IF lResult <> 0 THEN FUNCTION = buff
    END FUNCTION

    ------------------

    Leave a comment:


  • Roy Cline
    replied
    I did a search for "computer name" and the search returned (this web site)
    over 190 hits. You can use any Win Api call that would return
    the name. I am sure, I remember seeing how to do this being posted.

    ------------------
    Roy Cline

    [This message has been edited by Roy Cline (edited November 30, 2004).]

    Leave a comment:


  • Karl Skergeth
    started a topic How to get the name of the current computer ?

    How to get the name of the current computer ?

    Hi PBCC programmers !

    I want to get the network-name of the computer, on which
    my PBCC-exe is running.

    For example:
    The name of the computer is "notebook1".
    How to get this name into my Pbcc applikation ?

    Thank you and best regards.

    Karl

    ------------------
    Karl
Working...
X