ShellExecute -> Print sur plusieurs fichiers

Résolu/Fermé
mtR^ Messages postés 1211 Date d'inscription vendredi 17 juin 2011 Statut Membre Dernière intervention 3 juin 2023 - 19 mai 2017 à 12:43
mtR^ Messages postés 1211 Date d'inscription vendredi 17 juin 2011 Statut Membre Dernière intervention 3 juin 2023 - 2 juin 2017 à 11:50
Bonjour à tous,

Je souhaiterais imprimer une liste de fichiers .jpg

J'ai trouvé la commande ShellExecute avec l'argument print pour imprimer un fichier:

__fastcall TForm1::TForm1(TComponent* Owner)
	: TForm(Owner)
{
	UnicodeString test = "C:\\PROJETS\\C++\\GESTDOC_XE3\\gestdoc\\export pdf\\Collaboratif\\Diapositive1.jpg";
	UnicodeString cmd = "print";

	ShellExecute(Form1->Handle, cmd.c_str(), test.c_str(), NULL, NULL, SW_SHOWNORMAL);
}


Ça marche bien.
Mais je souhaiterais imprimer une liste de fichiers. J'ai tenté de mettre plusieurs fichiers dans "test" séparés par un espace, mais rien ne fonctionne. Est-ce faisable ?

Quand je suis dans Windows, je sélectionne plusieurs images d'un dossier, si je fait clic droit > Imprimer, j'ai bien toutes mes images prises en compte pour l'impression.
Est-ce un ShellExecute qui est effectué par Windows ?
Si oui, y a t-il un moyen pour observer les "commandes" faites par Windows ? Que je puisse essayer de les reproduire.

Merci.

A voir également:

3 réponses

[Dal] Messages postés 6174 Date d'inscription mercredi 15 septembre 2004 Statut Contributeur Dernière intervention 2 février 2024 1 083
Modifié le 19 mai 2017 à 13:07
Salut mtR^,

ShellExecute est une fonction de l'API de Windows.

Microsoft publie sa documentation sur MSDN :

https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea?redirectedfrom=MSDN

ShellExecute function

Performs an operation on a specified file.

HINSTANCE ShellExecute(
_In_opt_ HWND hwnd,
_In_opt_ LPCTSTR lpOperation,
_In_ LPCTSTR lpFile,
_In_opt_ LPCTSTR lpParameters,
_In_opt_ LPCTSTR lpDirectory,
_In_ INT nShowCmd
);

Parameters

hwnd [in, optional]

Type: HWND

A handle to the parent window used for displaying a UI or error messages. This value can be NULL if the operation is not associated with a window.

lpOperation [in, optional]

Type: LPCTSTR

A pointer to a null-terminated string, referred to in this case as a verb, that specifies the action to be performed. The set of available verbs depends on the particular file or folder. Generally, the actions available from an object's shortcut menu are available verbs. The following verbs are commonly used:

(...)

print

Prints the file specified by lpFile. If lpFile is not a document file, the function fails.

(...)

lpFile [in]

Type: LPCTSTR

A pointer to a null-terminated string that specifies the file or object on which to execute the specified verb. To specify a Shell namespace object, pass the fully qualified parse name. Note that not all verbs are supported on all objects. For example, not all document types support the "print" verb. If a relative path is used for the lpDirectory parameter do not use a relative path for lpFile.

(...)



Au vu de la doc, il semble bien que si tu veux imprimer plusieurs fichiers, il faille utiliser la fonction ShellExecute autant de fois que de fichiers à imprimer.

Dal
0
mtR^ Messages postés 1211 Date d'inscription vendredi 17 juin 2011 Statut Membre Dernière intervention 3 juin 2023 168
19 mai 2017 à 13:25
Salut Dal,

Merci pour la réponse ;)

Oui j'étais tombé sur cette doc aussi. J'ai déjà essayé de faire plusieurs ShellExecute à la suite, mais le problème est cela va m'ouvrir plusieurs fenêtres d'impression : une pour chaque image. Au lieu d'une seule fenêtre avec toutes les images dedans.

A+
0
mtR^ Messages postés 1211 Date d'inscription vendredi 17 juin 2011 Statut Membre Dernière intervention 3 juin 2023 168
2 juin 2017 à 11:50
Conclusion : impossible à réaliser avec ShellExecute (ça aurait été trop beau). Je suis passé par une librairie tierce.

Je ferme.
0