Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GetComputerName API Call
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Fonctions Windows API
Divers
Thread ID:
00227405
Message ID:
00227415
Vues:
22
>Greetings,
>
>I need to be able to get the computer name and I am having some difficulties. Below is my sample code.
>(VFP 3.0). I have also tried it my removing the @ symbol.
>
>**--Sample Code
>DECLARE INTEGER GetComputerName IN Win32API STRING @cReturnBuffer, INTEGER nBufferSize
>
>LOCAL lcresult, cReturnBuffer, nBufferSize
>lcresult = ""
>cReturnBuffer = SPACE(1024)
>nBufferSize = LEN(cReturnBuffer)
>
>nBufferSize = GetComputerName(@cReturnBuffer, nBufferSize)
>
>IF nBufferSize > 0
> lcresult = LEFT(cReturnBuffer, nBufferSize)
> ?lcresult
>ENDIF
>
>
>Thanks in advance,
>
Hi Scott,

Both parameters need to be passed by reference:
DECLARE SHORT GetComputerName IN Win32API;
  STRING @lpbuffer, INTEGER @nSize
lcbuffer = SPACE(260)
lnsize = LEN(lcbuffer)
llresult = (GetComputerName(@lcbuffer, @lnsize) # 0)
IF llresult
  ? LEFT(lcbuffer, lnsize)
ENDIF
The function actually returns a Boolean value. While a declaration of integer is probably more appropriate, I use a SHORT to help me distinguish the return value. In this case, a non-zero value equals true.

hth,
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform