PDA

Ver la Versión Completa : Directorios window.


rauros
23-09-2008, 18:15:00
Saludos a todos. Me gustaría saber como puedo usar los directorios tipo %Windows% o %root% . Sé que hay funciones en windows.dcu pero solo para algunos de los anteriores...

droguerman
23-09-2008, 18:36:13
Que es exactamente lo que deseas hacer

rauros
23-09-2008, 20:08:31
Crear directorios con CreateDirectory. Por ejemplo, si quiero poner en mis documentos una carpeta llamad mis juegos:

CreateDirectory(%User%+'/Mis documentos/Mis juegos');

seoane
23-09-2008, 20:39:37
Se me ocurre algo como esto:

function InsertarVariables(Str: String): String;
var
i: Integer;
EnvBlock, P: PChar;
begin
Result:= Str;
EnvBlock:= GetEnvironmentStrings;
if EnvBlock <> nil then
try
with TStringList.Create do
try
P:= EnvBlock;
while P^ <> #0 do
begin
if Pos('=',String(P)) > 1 then
Add(String(P));
inc(P,StrLen(P)+1);
end;
for i:= 0 to Count - 1 do
Result:= StringReplace(Result,'%'+ Names[i] +'%', ValueFromIndex[i],
[rfIgnoreCase,rfReplaceAll]);
finally
Free;
end;
finally
FreeEnvironmentStrings(EnvBlock);
end;
end;

// Por ejemplo
ShowMessage(InsertarVariables('%Windir%\miprograma.exe'));