Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Retrieving the windows path
Message
 
To
17/10/2001 08:22:38
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00569185
Message ID:
00569486
Views:
17
>>Yes, the system part will vary. On my machine, it's System32 (Win2K Pro). In order to avoid version dependence, I'd use the GetSystemDirectory API call.
DECLARE INTEGER GetSystemDirectory IN Win32API;
>>  STRING @lpbuffer, INTEGER uSize
>>lpbuffer = SPACE(260)
>>lnsize = LEN(lpbuffer)
>>lnresult = GetSystemDirectory(@lpbuffer, lnsize)
>>? LEFT(lpbuffer, lnresult)
For the sake of being on the safe side, you should probably check to make sure that lnresult in the above is greater than zero. If it isn't then GetLastError() will return the error info.
>
>George,
>
>Thanks very much. This works well.
>
>On my machine (Windows 98), I actually have both Windows\System and Windows\System32 folders. Your code shows the first one.
>
>It looks like the System32 (which has only a few files) was created by some program that hard-coded the path.
>
Hilmar,

I should note here that under Win2K and, I assume, XP as well, the system directory should be treated as if it's off-limits. Windows is very protective of this directory and, according to the Platform SDK:

"Applications should not create files in the system directory. If the user is running a shared version of the operating system, the application does not have write access to the system directory. Applications should create files only in the directory returned by the GetWindowsDirectory function."

FWIW, JUSTPATH(GETENV("COMSPEC")) also works on Win2K, but I don't have access right now to prior versions or XP available to text on right now.
George

Ubi caritas et amor, deus ibi est
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform