Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Stefan Wuebbe
 To: Ankur Joshi
  Where is Ankur Joshi?
 Surat, India
 Ankur Joshi
Subject: RE: Version Poblem
Thread ID: 331298 Message ID: 331300 # Views: 46 # Ratings: 0
Version: Visual FoxPro 9 Category: Operating Systems
Date: Wednesday, December 28, 2011 5:37:42 PM         

> Dear all,
> I am facing a problem with getenv("windir") command
> at my PC I get c:\Windows. But, at clients place it returns nothing.
> The client is using MS Windows XP Home Edition Version 2002 Service Pack 3, the processor is Intel Atom cpu n270 @ 1.60GHz
> Please help me out.
> Thanks.
> Men, Like Bullets, Go Farthest When They Are Smoothest. - Jean Paul Richter

Vfp's GetEnv() function evaluates O/S environment variables, so that it's the easiest way but also a little less reliable because users can poke around with their content via Win system settings or by having an invalid autoexec.BAT and so on.
So if you want to keep the easy way, one option might be to tell the clients that if they damage their Windows, it's their problem and not yours (because %windir% by default actually points to the "Windows" folder since Win95 AFAIR).

Or you can use the more reliable SHGetSpecialFolderPath() Win32API function in your code:
Declare Integer SHGetSpecialFolderPath in Shell32.dll ;
	Long hwndOwner, String @ lpszPath, Integer nFolder, Integer fCreate
Local str
str = SPACE(266)
SHGetSpecialFolderPath(0, @str, CSIDL_COMMON_WINDOWS, 0)
? "CSIDL_COMMON_WINDOWS:", Left(str, At(Chr(0), str)-1)



Version Poblem Posted by Ankur Joshi @ 12/28/2011 5:17:25 PM
RE: Version Poblem Posted by Stefan Wuebbe @ 12/28/2011 5:37:42 PM