Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to change windows path programmatically
Message
De
20/12/2004 02:53:12
 
 
À
19/12/2004 15:21:04
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00969441
Message ID:
00970503
Vues:
22
You're welcome Alejandro.

Note that GETENV('PATH') returns a string of max 255 chars (at least in vfp6sp5). So GetEnvironmentVariable() is more reliable.

>Thank you Gregory!
>
>That is actually more useful than changing the autoexec or whatever.
>
>Alex
>
>>>How can you change the windows path programmatically, in a way that takes into account the operating system version?
>>>
>>>TIA,
>>>
>>>Alex
>>
>>You can using a bit af api. This is for the running process and its children and is not permanent
>>
>>
>>function Do_it()
>>
>>	declare integer GetEnvironmentVariable in kernel32 ;
>>		string @lpName, ;	&& // environment variable name
>>		string @lpBuffer,;	&& // buffer for variable value
>>		integer nSize			&& // size of buffer
>>	
>>	declare integer SetEnvironmentVariable in kernel32 ;
>>		string @lpName,;	&& // environment variable name
>>		string @lpValue		&& // new value for variable
>>		
>>	
>>	local Success
>>	Success = TRUE
>>
>>	local s, n
>>	s = space(8192)
>>	
>>	do case
>>	case !m.Success
>>	
>>	otherwise
>>		n = GetEnvironmentVariable('PATH', @s, len(m.s))
>>		
>>	endcase
>>	
>>	do case
>>	case !m.Success
>>	
>>	case empty(m.n)
>>		assert FALSE
>>		Success = FALSE
>>	
>>	
>>	case empty(SetEnvironmentVariable('PATH', left(m.s, m.n) + ';c:\temp'))
>>		assert FALSE
>>		Success = FALSE
>>	
>>	endcase
>>	
>>	return m.Success
>>
>>	
>>endfunc
>>*---------------------------------------------------------------------------
>>
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform