Bonjour,

Ma présence sur ce forum est exceptionnelle car je développe mes projets en Delphi.

Le dernier en date doit utiliser une dll codée en C++ pour générer un menu et un sous menu dans un logiciel de simulation de vol et à partir de ces menus lancer deux petites applications utilitaires à la principale.

en voici le code récupéré sur un autre forum:
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// startDll.cpp*: définit les fonctions exportées pour l'application DLL.
//
 
#include <windows.h>
#include <tchar.h>
#include <stdio.h>
#include <tchar.h>
#include <Shlobj.h> 
#include "SimConnect.h"
 
 
static enum GROUP_ID {
	GROUP_MENU
};
 
static enum EVENT_ID {
	EVENT_MENU_START,
// 	EVENT_MENU_TWO,
};
 
HANDLE  hSimConnect = NULL;
static int quit = 0 ;
 
void CALLBACK MyDispatchProcMI(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext)
{
	HRESULT hr;
	switch(pData->dwID)
	{
	case SIMCONNECT_RECV_ID_EVENT:
		{
			SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData;
 
			switch(evt->uEventID)
			{
			case EVENT_MENU_START:
				{
					STARTUPINFO si = { 0 };
					si.cb = sizeof(si);
					si.dwFlags = STARTF_USESHOWWINDOW;
					si.wShowWindow = SW_SHOWNORMAL  ;
 
					PROCESS_INFORMATION pi = { 0 };
 
					TCHAR szFolderPath[MAX_PATH];
					hr = SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, SHGFP_TYPE_CURRENT, 
						szFolderPath);
 
					//****** Insert here the path to the prog you want to exec **************
 
					TCHAR pg[] =  L"\\Harperick\\Harperick v1\\client.exe\0" ;
 
					// Concat path + program name
					wcscat(szFolderPath, pg) ;
 
					::CreateProcess(NULL, szFolderPath, NULL, NULL, FALSE, 
						NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi) ;
 
					break;
				}
 
			default:
				break;
			}
			break;
		}
 
	case SIMCONNECT_RECV_ID_QUIT:
		{
			quit = 1;
			break;
		}
 
	default:
		printf("Received ID: %d", pData->dwID);
		break;
	}
}
 
int __stdcall DLLStart(void)
{
	HRESULT hr;
	// Place all initialization code for the client in this function
	if (SUCCEEDED(SimConnect_Open(&hSimConnect, "StartHarperick", NULL, 0, 0, 0)))
	{
		// Create some private events
		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_MENU_START);
// 		hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_MENU_TWO);
 
		hr = SimConnect_MenuAddItem(hSimConnect, "Start Harperick", EVENT_MENU_START, 12345);
 
		// Sign up for the notifications
		hr = SimConnect_AddClientEventToNotificationGroup(hSimConnect, GROUP_MENU, EVENT_MENU_START);
 
		hr = SimConnect_SetNotificationGroupPriority(hSimConnect, GROUP_MENU, SIMCONNECT_GROUP_PRIORITY_HIGHEST);
		SimConnect_CallDispatch(hSimConnect, MyDispatchProcMI, NULL);
	}
	return 0;
}
 
//
// The DLLStop function must be present.
//
void __stdcall DLLStop(void)
{
	// Close the client
	if (hSimConnect != NULL)
		HRESULT hr = SimConnect_Close(hSimConnect);
}
Je souhaiterais pouvoir attribuer au TCHAR pg[], une variable string dont le contenu est collectée dans un fichier texte au lieu de d'une chaîne statique car chaque utilisateur peut avoir une chemin différent pour l'application en question.

Absolument novice en C++ je souhaiterais avoir votre aide.

Merci de ce que vous pourrez faire.

Cordialement
Pierre