Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the value of Computer Name/Identification on a Local PC 1

Status
Not open for further replies.

CGR707

Programmer
Jul 7, 2002
20
PH
Hi,

Good day. I need to know on how to get the name/identification of a local computer using Visual Foxpro.
Thank you in advance.



 
Taken directly from the help:

Machine information must first be assigned by the network software and the network shell must be loaded.

If machine information has not been assigned or the network shell hasn't been loaded, SYS(0) returns a character string consisting of 15 spaces, a number sign (#) followed by another space, and then 0. Consult your network documentation for further information on defining machine information.

SYS(0) returns 1 when using Visual FoxPro in a stand-alone environment.

When the machine is connected to a network, SYS(0) returns the machine name, a space, a number sign (#) followed by another space, and then the id of the current user (or the security context in which Visual FoxPro is running). For example:

? SYS(0)

returns the following format:

MACHINEID # userid



Regards

Griff
Keep [Smile]ing
 
Another one I posted here before, reads the registry to get the registered user and company values.

The registry.PRG and .VCX work almost exactly the same. (Just change SET PROCEDURE TO (m.lcRegfile) ADDITIVE to SET CLASSLIB TO (m.lcRegfile) ADDITIVE, and RELEASE PROC (m.lcRegfile) to RELEASE CLASSLIB (m.lcRegfile).)

Here is a simple usage where I get the registered user and company name:
Code:
STORE "" TO lcRegName, lcRegCompany
= get_syslicense(@lcRegName, @lcRegCompany)
...

* Program....: GET_SYSLICENSE.PRG
* Version....: 1.0
* Author.....: ** Richard G Bean **
* Date.......: April 2, 1999
* Compiler...: Visual FoxPro 05.00.00.0415 for Windows

PARAMETERS p_cRegName, p_cRegCompany
LOCAL lcRegfile, oReg

STORE "" TO p_cRegName, p_cRegCompany

m.lcRegfile = "REGISTRY"
SET PROCEDURE TO (m.lcRegfile) ADDITIVE
oReg = CreateObject("Registry")

oReg.GetRegKey("DefName",@p_cRegName,;
   "Software\Microsoft\MS Setup (ACME)\User Info",oReg.nUserKey)
oReg.GetRegKey("DefCompany",@p_cRegCompany,;
   "Software\Microsoft\MS Setup (ACME)\User Info",oReg.nUserKey)
RELEASE PROC (m.lcRegfile)

IF EMPTY(p_cRegName)
   p_cRegName = "(Unknown)"
ENDIF && EMPTY(p_cRegName)
IF EMPTY(p_cRegCompany)
   p_cRegCompany = "(Unknown)"
ENDIF && EMPTY(p_cRegCompany)

RETURN .T.

*!* EOP: GET_SYSLICENSE.PRG
Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top