Basi,
ShellExecuteEx es la versión extendida de
ShellExecute.
Revisa este código:
Código Delphi
[-]
function ShellExecute_AndWait(Operation, FileName, Parameter, Directory: string;
Show: Word; bWait: Boolean): Longint;
var
FResult: Boolean;
Info: TShellExecuteInfo;
begin
FillChar(Info, SizeOf(Info), Chr(0));
Info.cbSize := SizeOf(Info);
Info.fMask := SEE_MASK_NOCLOSEPROCESS;
Info.lpVerb := PChar(Operation);
Info.lpFile := PChar(FileName);
Info.lpParameters := PChar(Parameter);
Info.lpDirectory := PChar(Directory);
Info.nShow := Show;
FResult := ShellExecuteEx(@Info);
if FResult then
begin
if bWait then
begin
while
WaitForSingleObject(Info.hProcess, 100) = WAIT_TIMEOUT
do Application.ProcessMessages;
FResult := GetExitCodeProcess(Info.hProcess, DWORD(Result));
end
else
Result := 0;
end;
if not FResult then Result := -1;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ShellExecute_AndWait('print','msPaint','d:\image1.bmp','',SW_SHOWNORMAL,False);
end;
Al ejecutar el código anterior se muestra el siguiente mensaje:
Cita:
This file does not have a program associated with it for performing this action. Please install a program or, if one is already, create an association in the Default Programs control panel.
|
Conclusión: MsPaint no soporta la impresión vía parámetros, debes buscar un programa que la soporte y luego puedes imprimirlo por medio del siguiente código:
Código Delphi
[-]
ShellExecute(Handle,'print','d:\image1.bmp', nil, nil, SW_SHOWNORMAL);
Espero sea útil
Nelson.