Page 1 of 1

Funcion GetComputerName()

Posted: Wed Oct 02, 2013 6:01 pm
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

Re: Funcion GetComputerName()

Posted: Wed Oct 02, 2013 6:29 pm
by danielmaximiliano
Hola Mario:
estoy utilizando esto en mi aplicacion de red

Code: Select all

Public cDefaultUser    := GETENV( "UserName"     ) 
Public cDefaulMachine:= GETENV( "COMPUTERNAME" )

Funcion GetComputerName()

Posted: Wed Oct 02, 2013 10:34 pm
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.

Funcion GetComputerName()

Posted: Wed Oct 02, 2013 10:46 pm
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 ! :)

Re: Funcion GetComputerName()

Posted: Thu Oct 03, 2013 12:53 am
by Mario Mansilla
Hola Daniel , Pablo :
Perfecto , ambas soluciones funcionan :)
Muchas gracias
Saludos
Mario Mansilla