Funcion GetComputerName()

Moderator: Rathinagiri

Post Reply
Mario Mansilla
Posts: 269
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Funcion GetComputerName()

Post by Mario Mansilla »

Hola :
Necesito obtener el nombre de la pc donde se esta ejecutando la aplicacion y al colocar la funcion GetComputerName() me da error y no se crea el ejecutable .
Tengo que agregar alguna libreria extra ?
Uso Hmg 3.046 + Ide

Hello:
I need to get the name of the PC where you are running the application and place the GetComputerName function () it gives me error and creates the executable.
I have to add any additional library?
I use Hmg 3.046 + Ide

Saludos
Mario Mansilla
User avatar
danielmaximiliano
Posts: 2612
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Contact:

Re: Funcion GetComputerName()

Post by danielmaximiliano »

Hola Mario:
estoy utilizando esto en mi aplicacion de red

Code: Select all

Public cDefaultUser    := GETENV( "UserName"     ) 
Public cDefaulMachine:= GETENV( "COMPUTERNAME" )
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`. Harbour/HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. := +54901169026142
Telegram Name := DaNiElMaXiMiLiAnO
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Funcion GetComputerName()

Post by Pablo César »

Mario Mansilla wrote:Necesito obtener el nombre de la pc donde se esta ejecutando la aplicacion y al colocar la funcion GetComputerName() me da error
Mario, podria disponibilizar el mensaje de error ?

Porque yo lo utilizo GetComputerName() sin problemas.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Funcion GetComputerName()

Post by Pablo César »

In the fact in HMG this function there is not present, sorry. But this is not considered as BUG, so please note following code added:

Code: Select all

#include <hmg.ch>

Function Main()
MsgInfo(GetComputerName())
MsgInfo(GetUserName())
Return Nil

#pragma BEGINDUMP

#include <windows.h>
#include <lmcons.h>

HB_FUNC( GETUSERNAME )
{
   TCHAR lpBuffer[ UNLEN + 1 ];
   DWORD nSize = UNLEN;

   GetUserName( lpBuffer, &nSize );

   hb_retc( lpBuffer );
}
HB_FUNC( GETCOMPUTERNAME )
{
   TCHAR lpBuffer[ 129 ];
   DWORD nSize = 128;

   GetComputerName( lpBuffer, &nSize );

   hb_retc( lpBuffer );
}
#pragma ENDDUMP
I hope you enjoy it ! :)
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Mario Mansilla
Posts: 269
Joined: Wed Aug 13, 2008 2:35 pm
Location: Córdoba - Argentina

Re: Funcion GetComputerName()

Post by Mario Mansilla »

Hola Daniel , Pablo :
Perfecto , ambas soluciones funcionan :)
Muchas gracias
Saludos
Mario Mansilla
Post Reply