Cette source montre, entre autres, l'utilisation des fonctions:
- SetErrorMode(...)
- MessageBoxIndirect(...)
Source / Exemple :
//---------------------------------------------------------------------
// isDiskInDrive.c
//---------------------------------------------------------------------
#include <windows.h>
//---------------------------------------------------------------------
BOOL isDiskInDrive(void)
{
WIN32_FIND_DATA ffd = {0};
UINT pem = SetErrorMode(SEM_FAILCRITICALERRORS);
HANDLE hff = FindFirstFile( "A:\\*.*", &ffd );
BOOL bok = GetLastError() != ERROR_NOT_READY;
if(hff != INVALID_HANDLE_VALUE) FindClose(hff);
SetErrorMode(pem);
return bok;
}
//--------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hpinst, LPSTR p, int n )
{
int reponse;
MSGBOXPARAMS mbp = {sizeof(MSGBOXPARAMS)};
mbp.hInstance = LoadLibrary("Shell32");
mbp.lpszCaption = "isDiskInDrive";
mbp.dwStyle = MB_RETRYCANCEL | MB_DEFBUTTON1 | MB_USERICON;
do
{
if(isDiskInDrive())
{
mbp.lpszIcon = MAKEINTRESOURCE(8);
mbp.lpszText = "Il y a une disquette dans le lecteur A: ";
reponse = MessageBoxIndirect(&mbp);
}
else
{
mbp.lpszIcon = MAKEINTRESOURCE(7);
mbp.lpszText = "Il n'y a pas de disquette dans le lecteur A: ";
reponse = MessageBoxIndirect(&mbp);
}
}while(reponse == IDRETRY);
FreeLibrary(mbp.hInstance);
return 0;
}
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.