hrp
Messages postés24Date d'inscriptionmardi 18 janvier 2005StatutMembreDernière intervention17 juin 2006 8 févr. 2005 à 10:03
ok, j'ai regarder dans la sdk windows ce que fait cette fonciton:
---------------------------------
The SendMessageTimeout function sends the specified message to a window or windows. The function calls the window procedure for the specified window and, if the specified window belongs to a different thread, does not return until the window procedure has processed the message or the specified time-out period has elapsed. If the window receiving the message belongs to the same queue as the current thread, the window procedure is called directly - the time-out value is ignored.
LRESULT SendMessageTimeout(
HWND hWnd, // handle of destination window
UINT Msg, // message to send
WPARAM wParam, // first message parameter
LPARAM lParam, // second message parameter
UINT fuFlags, // how to send the message
UINT uTimeout, // time-out duration
LPDWORD lpdwResult // return value for synchronous call
);
Parameters
hWnd
Identifies the window whose window procedure will receive the message. If this parameter is HWND_TOPMOST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows.
Specifies how to send the message. This parameter can be a combination of the following values:
Value Meaning
SMTO_ABORTIFHUNG Returns without waiting for the time-out period to elapse if the receiving process appears to be in a "hung" state.
SMTO_BLOCK Prevents the calling thread from processing any other requests until the function returns.
SMTO_NORMAL The calling thread is not prevented from processing other requests while waiting for the function to return.
uTimeout
Specifies the duration, in milliseconds, of the time-out period.
lpdwResult
Specifies the result of the message processing and depends on the message sent.
Return Values
If the function succeeds, the return value is TRUE.
If the function fails, the return value is FALSE. To get extended error information, call GetLastError.
--------------------------------------
mon but, c'est de savoir si ma fenêtre internet explorer fonctionne encore ("en cours d'exécution") ou si son proccessus est bloqué ("sans réponse"). pour réaliser cela que dois-je passer en argument à la fonction "SendMessageTimeout", notement les arguments:
-UINT Msg
-WPARAM wParam
-LPARAM lParam
BruNews
Messages postés21040Date d'inscriptionjeudi 23 janvier 2003StatutModérateurDernière intervention21 août 2019 8 févr. 2005 à 13:00
Tu envoies nimporte quoi du moment que ça ne provoque pas une cata, fais quelques tests, du genre:
DWORD r;
if(!SendMessageTimeout(hwnd,WM_COMMAND,12, 0,SMTO_ABORTIFHUNG,1000,&r) {
if(!GetLastError()) ProgEstBloque;
}
WM_COMMAND,12,0
sont totalement arbitraires, teste ce qui va bon dans ton cas.
ShareVB
Messages postés2676Date d'inscriptionvendredi 28 juin 2002StatutMembreDernière intervention13 janvier 201626 8 févr. 2005 à 20:34
salut,
le guideline de Microsoft tend à dire : un timeout de 5 secondes et le message WM_NULL envoyé (avec SendMessageTimeout)...mais il y a un problème (je ne sais pas avec du C mais je l'ai rencontré avec VB)...
Si l'application ne répond pas, SendMessageTimeout ne renvoie la main que dans 5 secondes pendant lesquelles le thread qui a appelé SendMessageTimeout ne répond pas...et si c'est celui d'une fenêtre, c'est embettant...
il existe les fonctions IsHungAppWindow (pour NT/2K:XP) et IsHungThread (pour 9x) qui rendent (en principe) immédiatement la main même en cas de "hung"...
BruNews
Messages postés21040Date d'inscriptionjeudi 23 janvier 2003StatutModérateurDernière intervention21 août 2019 8 févr. 2005 à 20:52
Cette fonction fait bien son boulot actuellement mais MSDN est sans ambiguité sur son avenir:
It is recommended that you do not use it in new programs because it might be altered or unavailable in subsequent versions of Windows.