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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get sever/computer name

Status
Not open for further replies.

manpaul

Technical User
Jan 10, 2005
118
CA
I need to get the computername / Servername for the computer where the vfp exe was run from.

I will have a directory where I will be storing pictures. The directory will not change and will be on the computer where the exe is run from. The dir structure will be as follows main directory with the exe and dbc and dbf's under the main directory I will have a picture directory under the main directory. What I want to do is capture the computersname and main directory as soon as the exe is run, store it into a public variable so I can create a unc path to the picture directory to use with the program when need to retreive or store pictures. The computername and main directory will change depending on where the person has installed the system.

Paul
 
What you need to do is use relative paths rather than hard paths.

main directory will be like \\SomeServer\foxapps\myapp\
(all your dbf's, exe's are in myapp)
images will be in like: \\SomeServer\foxapps\myapp\images\

Your exe will be say in myapp directory and the shortcut the user has will have 'start in' set to: \\SomeServer\foxapps\myapp\

Also lets say you have the image names in a table called images.dbf with a field name of char type called 'imgname'.

Now lets say you have an image object and now you want to call the image. All you need to do is:
...picture = ".\images\"+ALLTRIM(images.imgname)

This says 'relative to my current path move up to images folder and the image name in the image table is .. whatever is the current value of the field 'image_name' of the image.dbf.

Using a .\foldername indicates to start at the relative current path and go forward to the 'foldername'. You can also use ..\ to move down 1 in the path chain.

Key thing here is you either need to set make sure the user has a shortcut to the exe which has the 'start in' set to wherever the main directory of the app is. You can have your install create this shortcut based on where it is installed.

No matter where the main directory is if the sub-folders under it are always the same using .\xxx is the best method to get to them or any other subfolders. I always store things in their own folders, dbf, exe, pjx, etc.
Keeps things nice and tiddy.




Regards,

Rob
 

Paul


Foxpro's Sys(0) should give you the computername.

Time is the father of truth. Time will tell.
-------------------------------------------
Benson O. A. (Infinity Link Limited)
 
SYS(0) will give me the name of the users computer not the computer where the program exe is run from.

Rob you explained what I am trying to do, but the user can install the exe and supporting file where he/she wants. So I must be able to get the //Severname//main directory when the exe starts so I can setup the "soft path". What I need to know so when the exe first executes can I get the servername/computer name of where the exe is run from, then setup the picturepath = //severname/main directory/pictures

Paul
 
Not sure why you need a UNC, but sys(16) returns the full path and filename of the executing program.

Mike Krausnick
Dublin, California
 
Thanks Mike I thing that one will work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top