Problème avec fichier manifest

Sceyllia Messages postés 8 Date d'inscription mercredi 8 août 2007 Statut Membre Dernière intervention 21 mars 2013 - 22 juin 2011 à 17:27
Sceyllia Messages postés 8 Date d'inscription mercredi 8 août 2007 Statut Membre Dernière intervention 21 mars 2013 - 7 juil. 2011 à 14:57
Bonjour à tous,

J'aurais besoin de l'avis de connaisseurs en c/c++ pour m'éclairer sur le soucis que j'ai depuis quelques
semaines concernant ce morceau de code qui m'agace prodigieusement.

Voilà, quand je compile ce code sans inclure le fichier "manifest" tout va pour le mieux dans le meilleure
des mondes, mais si je l'inclus dans l'exécutable j'ai le droit a un super crash du programme.

Est-ce que quelqu'un pourrait m'éclairer sur ce phénomène ?

Étant super débutant en programmation, j'espère que je ne choquerais pas les puristes par
la mauvaise présentation de ce code.

Une remarque toutefois : je poste ce message car je n'arrive vraiment pas à trouver de solution et ce
malgré de nombreuses recherches sur la toile, donc si une âme charitable voudrait bien me mettre sur la voie
ça serait super sympa.

Merci d'avance.



#include <windows.h>
#include <Winioctl.h>
#include <stdio.h>

char g_strdrive[2];

bool diskDoor(char drive, bool eject)
{
char Drive[MAX_PATH];
HANDLE hDrive = INVALID_HANDLE_VALUE;

BOOL bRetVal = TRUE;
DWORD dwDummy;

sprintf(Drive,"\\\\.\\%c:", drive );

if(hDrive == INVALID_HANDLE_VALUE)

{

hDrive = CreateFile(Drive, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}


{
if(eject)

{
bRetVal = DeviceIoControl(hDrive, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &dwDummy, NULL);
}

else

{
bRetVal = DeviceIoControl(hDrive, IOCTL_STORAGE_LOAD_MEDIA, NULL, 0, NULL, 0, &dwDummy, NULL);
}

return 0;

}
}
enum { ID_LABEL = 1,ID_BUTTON0,ID_BUTTON1,ID_CB0,ID_BUTTON2};


LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);

HWND button0, button1, button2, cb;
HINSTANCE hinst, g_hInst;

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
HWND hWnd;
MSG msg;
WNDCLASS wc;

hinst = hinstance;

wc.style = 0;
wc.lpfnWndProc = MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hinstance;
wc.hIcon = LoadIcon(hinstance,MAKEINTRESOURCE(0));
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
wc.lpszMenuName = NULL;
wc.lpszClassName = "Main";

if(!RegisterClass(&wc)) return FALSE;

hWnd = CreateWindow("Main","Ouverture/Fermeture CD",(WS_OVERLAPPED|WS_SYSMENU), 550, 400, 510, 180, NULL, NULL, hinstance, NULL);

if (!hWnd) return FALSE;

ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);

while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}

LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)

{
switch (msg)
{

case WM_CREATE:
{
cb = CreateWindow("COMBOBOX","", WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, 90,35,320,150, hWnd,(HMENU)ID_CB0,g_hInst,0);
SendMessage(cb, CB_ADDSTRING, (WPARAM) 1, (LPARAM) (long) "G:");
SendMessage(cb, CB_ADDSTRING, (WPARAM) 1, (LPARAM) (long) "H:");
SendMessage(cb, CB_ADDSTRING, (WPARAM) 1, (LPARAM) (long) "I:");
CreateWindow("Button","Charger",BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE ,200,90,80,26,hWnd,(HMENU)ID_BUTTON0,g_hInst,0);
CreateWindow("Button","Éjecter",BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE ,80,90,80,26,hWnd,(HMENU)ID_BUTTON1,g_hInst,0);
CreateWindow("Button","Quitter",BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE ,340,90,80,26,hWnd,(HMENU)ID_BUTTON2,g_hInst,0);

case WM_INITDIALOG:
{
DlgDirListComboBox(hWnd,0,ID_CB0,0,CB_ADDSTRING);
SendDlgItemMessage(hWnd,ID_CB0,LB_SETCURSEL,0,0);
return TRUE;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_BUTTON1:
{
DlgDirSelectComboBoxEx(hWnd,g_strdrive,2,ID_CB0);
if(!diskDoor(g_strdrive[0],TRUE))
return TRUE;
}
case ID_BUTTON0:
DlgDirSelectComboBoxEx(hWnd,g_strdrive,2,ID_CB0);
if(!diskDoor(g_strdrive[0],FALSE))

return TRUE;

case ID_CB0:
return 0;

case ID_BUTTON2:{PostQuitMessage(0);
break;
}
}
case WM_DESTROY:
PostQuitMessage(0);
return 0;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
}
}

2 réponses

racpp Messages postés 1909 Date d'inscription vendredi 18 juin 2004 Statut Modérateur Dernière intervention 14 novembre 2014 17
6 juil. 2011 à 02:46
Salut,
Mets le contenu de ton fichier manifest pour qu'on puisse tester et essayer de voir ce qui ne va pas.
0
Sceyllia Messages postés 8 Date d'inscription mercredi 8 août 2007 Statut Membre Dernière intervention 21 mars 2013
7 juil. 2011 à 14:57
Salut racpp,

Merci pour ta réponse, c'est sympa.

Le ficher manifest que j'inclus dans l'exécutable est le suivant :




<?xml version="1.0" encoding="UTF-8" standalone="yes"?>


<description></description>
<dependency>
<dependentAssembly>

</dependentAssembly>
</dependency>


Dès que je compile et exécute il n'y a rien a faire cela crash systématiquement

Merci encore pour l'aide.
0
Rejoignez-nous