Bonjour,

je vois dans la doc de ShellExecuteInfo que les différents parametres à passer à ShellExecute doivent l'être séparés par des espaces.

Comment faire si au moins 1 parametre (chemin de fichier) contient aussi au moins un espace.

Merci pour vos conseils.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//---------------------------------------------------------------------------
//# bool TForm1::Execute(FileName)
//   Execute an application
//---------------------------------------------------------------------------
void __fastcall  TVisdrawForm1::Execute_Program(String FileName, String  parametres)
{
  SHELLEXECUTEINFO execinfo;      // Structure ShellExecute(Ex) info

  //typedef struct _SHELLEXECUTEINFO {
  //	DWORD cbSize;
  //	ULONG fMask;
  //	HWND hwnd;
  //	LPCTSTR lpVerb;
  //	LPCTSTR lpFile;
  //	LPCTSTR lpParameters;
  //	LPCTSTR lpDirectory;
  //	int nShow;
  //	HINSTANCE hInstApp;
  //	LPVOID lpIDList;
  //	LPCTSTR lpClass;
  //	HKEY hkeyClass;
  //	DWORD dwHotKey;
  //	union {
  //		HANDLE hIcon;
  //		HANDLE hMonitor;
  //	} DUMMYUNIONNAME;
  //	HANDLE hProcess;
  //} SHELLEXECUTEINFO, *LPSHELLEXECUTEINFO;
 String action;                                 // action to run

  action =  "open";
  memset(&execinfo, 0, sizeof(execinfo));
  execinfo.lpFile = FileName.c_str();          // programme
  execinfo.cbSize = sizeof(execinfo);
  execinfo.lpVerb = action.c_str();             // Action = Open
  execinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
  execinfo.nShow = SW_SHOWDEFAULT;
  execinfo.lpParameters = parametres.c_str();   // Parms
  execinfo.nShow = SW_SHOW;
  ShellExecuteEx(&execinfo);