Ver Mensaje Individual
  #5  
Antiguo 14-09-2007
Avatar de BlueSteel
[BlueSteel] BlueSteel is offline
Miembro Premium
 
Registrado: may 2003
Ubicación: Concepción - Chile
Posts: 2.310
Reputación: 24
BlueSteel Va por buen camino
Ya lo puede hacer

Hola Saone...

al final realice lo sgte para ejecutarlo

utilice la funcion GetUserName para optener el nombre de usuario....

Código Delphi [-]
Function GetUserName:String;
Var
   PcUser  : PChar;
   DwUsize : DWord;
Begin
   DwUsize := 21;
   GetMem( PcUser, DwUsize);
   Try
      If Windows.GetUserName( PcUser, DwUsize ) then
         Result := PcUser
   Finally
      FreeMem( PcUser );
   End;
End;



con esto
Código Delphi [-]
If not DirectoryExists(Concat('C:\Documents and Settings\',GetUserName,'.Dominio)) Then

pregunto si existe el directorio Usuario.Dominio...si es así, ejecuto

Código Delphi [-]
Archivo1 := Concat('C:\Documents and Settings\',GetUserName,'\Datos de programa\Microsoft\Diseños de fondo\FondoA.jpg');
CopyFile(PChar('\\Servidor\Stationery\Fondo de Huachipato.jpg'),PChar(Archivo1),FALSE);


Esto me funciona bien desde un Form Visual, pero quiero traspasarlo a un Console Application, pero no se cual seria la estructura correcta (hace mucho tiempo que deje el turbo pascal.. y ando perdido entero....

hasta el momento tengo esto... pero me da errores...


Código Delphi [-]
program Project1;
Uses
  FileCtrl;  // Para el DirectoryExists
{$APPTYPE CONSOLE}
Type
   Private
   Function GetUserName:String;
   End;
Var
  Archivo1, Archivo2 : String;
uses
  SysUtils;
Function GetUserName:String;
Var
   PcUser  : PChar;
   DwUsize : DWord;
Begin
   DwUsize := 21;
   GetMem( PcUser, DwUsize);
   Try
      If Windows.GetUserName( PcUser, DwUsize ) then
         Result := PcUser
   Finally
      FreeMem( PcUser );
   End;
End;
begin
    If not DirectoryExists(Concat('C:\Documents and Settings\',GetUserName,'.Dominio)) Then
       Begin
            Archivo1 := Concat('C:\Documents and Settings\',GetUserName,'\Datos de programa\Microsoft\Diseños de fondo\FondoA.jpg');
            Archivo2 := Concat('C:\Documents and Settings\',GetUserName,'\Datos de programa\Microsoft\Diseños de fondo\FondoA.htm');
       End
    Else
       Begin
            Archivo1 := Concat('C:\Documents and Settings\',GetUserName,'.Dominio\Datos de programa\Microsoft\Diseños de fondo\FondoA.jpg');
            Archivo2 := Concat('C:\Documents and Settings\',GetUserName,'.Dominio\Datos de programa\Microsoft\Diseños de fondo\FondoA.htm');
       End;
     CopyFile(PChar('\\Servidor\Stationery\FondoA.jpg'),PChar(Archivo1),FALSE);
     CopyFile(PChar('\\Servidor\Stationery\FondoA.jpg'),PChar(Archivo2),FALSE);
end.

Me podrias ayudar un poco con este codigo....
__________________
BlueSteel

Última edición por BlueSteel fecha: 14-09-2007 a las 16:19:02.
Responder Con Cita