Ver Mensaje Individual
  #10  
Antiguo 04-03-2009
tocomi tocomi is offline
Miembro
 
Registrado: may 2006
Posts: 45
Reputación: 0
tocomi Va por buen camino
Yo uso esta funcion para poder imprimir en matriz de puntos, tuve que hacer algunas modificaciones pero nada del otro mundo, antes genero el informe en un plano y despues lo envia a impresora, sin ningun problema, hasta me di el gusto de ajustarlo para que lo hiciera a impresoras remotas en una red de windows XP (captura el puerto, lo envia a imprimir y despues lo descaptura)

Código:
 
procedure TForm1.Button1Click(Sender: TObject);
 
function DOSExe(Fichero,Parametros,Titulo:String):Boolean;
 
    function WinExecAndWait32(FileName:String; Visibility:integer):integer;
    var 
      zAppName:array[0..512] of char;
      zCurDir:array[0..255] of char;
      WorkDir:String;
      StartupInfo:TStartupInfo;
      ProcessInfo:TProcessInformation;
      Resultado,exitCode: DWord;
      Titulo:Array [0..200] of char;
      kk:DWord;
    begin 
      StrPCopy(zAppName,FileName);
      GetDir(0,WorkDir);
      StrPCopy(zCurDir,WorkDir);
      FillChar(StartupInfo,Sizeof(StartupInfo),#0);
      StartupInfo.cb := Sizeof(StartupInfo);
 
      StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
      StartupInfo.wShowWindow := Visibility;
      CreateProcess(nil,
        zAppName,                      { pointer to command line string }
        nil,                           { pointer to process security attributes}
        nil,                           { pointer to thread security attributes}
        false,                         { handle inheritance flag }
        CREATE_NEW_CONSOLE or          { creation flags }
        NORMAL_PRIORITY_CLASS,
        nil,                           { pointer to new environment block }
        nil,                           { pointer to current directory name }
        StartupInfo,                   { pointer to STARTUPINFO }
        ProcessInfo);
 
      {Espera a que termine la ejecucion}
      {Wait until execution finish}
      repeat 
        exitCode := WaitForSingleObject( ProcessInfo.hProcess,1000);
        Application.ProcessMessages;
        GetExitCodeThread(ProcessInfo.hProcess,kk);
 
      until (exitCode <> WAIT_TIMEOUT);
      GetExitCodeProcess(ProcessInfo.hProcess,Resultado);
      MessageBeep(0);
      CloseHandle(ProcessInfo.hProcess );
      Result:=Resultado;
    end; {WinExecAndWait32}
 
  var {DOSExe}
    f          :file;
    PathPif,
    DirTrabajo,
    DP         :string;  {Datos del Pif}
    ErrorIO       :integer;
 
  begin 
    {Datos de un fichero PIF preparado para Cerrar al Terminar}
    {A PIF file data prepared to 'Close at End'}
    DP:=
    #0#120#84#69#83#84#68#79#126#49#32#32#32#32#32#32#32#32#32#32+
    #32#32#32#32#32#32#32#32#32#32#32#32#128#2#0#0#68#58#92#116#101+
    #115#116#100#111#115#112#114#111#103#114#97#109#116#104#105#110+
    #103#46#101#120#101#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#16#0#101#58#92#116#101#109#112+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#45#101#120+
    #32#100#58#92#116#101#115#116#32#100#58#92#42#46#42#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#1#0#255#25#80#0#0#7#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#77#73+
    #67#82#79#83#79#70#84#32#80#73#70#69#88#0#135#1#0#0#113#1#87#73+
    #78#68#79#87#83#32#51#56#54#32#51#46#48#0#5#2#157#1#104#0#128+
    #2#0#0#100#0#50#0#255#255#0#0#255#255#0#0#2#0#2#0#159#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#45#101#120#32#100#58#92#116#101+
    #115#116#32#100#58#92#42#46#42#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#87+
    #73#78#68#79#87#83#32#86#77#77#32#52#46#48#0#255#255#27#2#172+
    #1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#80#73#70+
    #77#71#82#46#68#76#76#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#2#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#129#0#0#0#0#0#0#0#0#0#0#0#1#0#0#0#5#0#25#0#3#0#200#0+
    #232#3#2#0#10#0#1#0#0#0#0#0#0#0#28#0#0#0#0#0#0#0#8#0#12#0#84#101+
    #114#109#105#110#97#108#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#76#117#99#105#100#97#32#67#111#110#115#111#108#101+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#3#0#0#0#80#0#25#0#128+
    #2#44#1#0#0#0#0#22#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0+
    #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#1#0;
 
    Titulo:=Titulo+StringOfChar(' ',30-Length(Titulo));
    Titulo:=Copy(Titulo,1,30)+#0;
    move(Titulo[1],DP[$02+1],30);
 
    Fichero:=copy(Fichero,1,63)+#0;
    move(Fichero[1],DP[$24+1],length(Fichero));
 
    Parametros:=copy(Parametros,1,63)+#0;
    move(Parametros[1],DP[$a5+1],length(Parametros));
    move(Parametros[1],DP[$1c5+1],length(Parametros));
 
    DirTrabajo:=Copy(extractfilepath(Fichero),1,63)+#0;
    move(DirTrabajo[1],DP[$65+1],length(DirTrabajo));
 
    Result:=false;
    PathPif:=ExtractFilePath(Application.ExeName)+'UnPif.pif';
    assignfile(f,PathPif);
    rewrite(f,1);
    ErrorIO:=ioresult;
    blockwrite(f,DP[1],length(DP),ErrorIO);
    closefile(f);
    if ErrorIO<>length(DP) then exit;
 
    WinExecAndWait32(PathPif,Sw_ShowNormal);
 
    DeleteFile(PathPif);
    Result:=TRUE;
  end; {DOSExe}
 
begin 
  DOSExe('c:\tools\q.exe','c:\autoexec.bat','Ejemplo de llamada del QEdit');
end;
Responder Con Cita