kernel32: Add SetThreadErrorMode and GetThreadErrorMode.

This commit is contained in:
Peter Rosin 2010-02-03 14:37:35 +01:00 committed by Alexandre Julliard
parent e8a32ec2b8
commit 805f7d79db
4 changed files with 66 additions and 1 deletions

View File

@ -643,6 +643,7 @@
@ stdcall GetTempPathA(long ptr) @ stdcall GetTempPathA(long ptr)
@ stdcall GetTempPathW(long ptr) @ stdcall GetTempPathW(long ptr)
@ stdcall GetThreadContext(long ptr) @ stdcall GetThreadContext(long ptr)
@ stdcall GetThreadErrorMode()
@ stdcall GetThreadId(ptr) @ stdcall GetThreadId(ptr)
# @ stub GetThreadIOPendingFlag # @ stub GetThreadIOPendingFlag
@ stdcall GetThreadLocale() @ stdcall GetThreadLocale()
@ -1056,6 +1057,7 @@
@ stdcall SetTermsrvAppInstallMode(long) @ stdcall SetTermsrvAppInstallMode(long)
@ stdcall SetThreadAffinityMask(long long) @ stdcall SetThreadAffinityMask(long long)
@ stdcall SetThreadContext(long ptr) @ stdcall SetThreadContext(long ptr)
@ stdcall SetThreadErrorMode(long ptr)
@ stdcall SetThreadExecutionState(long) @ stdcall SetThreadExecutionState(long)
@ stdcall SetThreadIdealProcessor(long long) @ stdcall SetThreadIdealProcessor(long long)
@ stdcall SetThreadLocale(long) @ stdcall SetThreadLocale(long)

View File

@ -1221,7 +1221,7 @@ static void test_ThreadErrorMode(void)
if (!pSetThreadErrorMode || !pGetThreadErrorMode) if (!pSetThreadErrorMode || !pGetThreadErrorMode)
{ {
skip("SetThreadErrorMode and/or GetThreadErrorMode unavailable (added in Windows 7)\n"); win_skip("SetThreadErrorMode and/or GetThreadErrorMode unavailable (added in Windows 7)\n");
return; return;
} }

View File

@ -651,3 +651,64 @@ DWORD WINAPI GetCurrentThreadId(void)
} }
#endif /* __i386__ */ #endif /* __i386__ */
/*************************************************************************
* rtlmode_to_win32mode
*/
static DWORD rtlmode_to_win32mode( DWORD rtlmode )
{
DWORD win32mode = 0;
if (rtlmode & 0x10)
win32mode |= SEM_FAILCRITICALERRORS;
if (rtlmode & 0x20)
win32mode |= SEM_NOGPFAULTERRORBOX;
if (rtlmode & 0x40)
win32mode |= SEM_NOOPENFILEERRORBOX;
return win32mode;
}
/***********************************************************************
* SetThreadErrorMode (KERNEL32.@)
*/
BOOL WINAPI SetThreadErrorMode( DWORD mode, LPDWORD oldmode )
{
NTSTATUS status;
DWORD tmp = 0;
if (mode & ~(SEM_FAILCRITICALERRORS |
SEM_NOGPFAULTERRORBOX |
SEM_NOOPENFILEERRORBOX))
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if (mode & SEM_FAILCRITICALERRORS)
tmp |= 0x10;
if (mode & SEM_NOGPFAULTERRORBOX)
tmp |= 0x20;
if (mode & SEM_NOOPENFILEERRORBOX)
tmp |= 0x40;
status = RtlSetThreadErrorMode( tmp, oldmode );
if (status)
{
SetLastError( RtlNtStatusToDosError(status) );
return FALSE;
}
if (oldmode)
*oldmode = rtlmode_to_win32mode(*oldmode);
return TRUE;
}
/***********************************************************************
* GetThreadErrorMode (KERNEL32.@)
*/
DWORD WINAPI GetThreadErrorMode( void )
{
return rtlmode_to_win32mode( RtlGetThreadErrorMode() );
}

View File

@ -1762,6 +1762,7 @@ WINBASEAPI DWORD WINAPI GetTickCount(void);
WINBASEAPI ULONGLONG WINAPI GetTickCount64(void); WINBASEAPI ULONGLONG WINAPI GetTickCount64(void);
WINBASEAPI DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION); WINBASEAPI DWORD WINAPI GetTimeZoneInformation(LPTIME_ZONE_INFORMATION);
WINBASEAPI BOOL WINAPI GetThreadContext(HANDLE,CONTEXT *); WINBASEAPI BOOL WINAPI GetThreadContext(HANDLE,CONTEXT *);
WINBASEAPI DWORD WINAPI GetThreadErrorMode(void);
WINBASEAPI INT WINAPI GetThreadPriority(HANDLE); WINBASEAPI INT WINAPI GetThreadPriority(HANDLE);
WINBASEAPI BOOL WINAPI GetThreadPriorityBoost(HANDLE,PBOOL); WINBASEAPI BOOL WINAPI GetThreadPriorityBoost(HANDLE,PBOOL);
WINBASEAPI BOOL WINAPI GetThreadSelectorEntry(HANDLE,DWORD,LPLDT_ENTRY); WINBASEAPI BOOL WINAPI GetThreadSelectorEntry(HANDLE,DWORD,LPLDT_ENTRY);
@ -2096,6 +2097,7 @@ WINBASEAPI DWORD WINAPI SetTapeParameters(HANDLE,DWORD,LPVOID);
WINBASEAPI DWORD WINAPI SetTapePosition(HANDLE,DWORD,DWORD,DWORD,DWORD,BOOL); WINBASEAPI DWORD WINAPI SetTapePosition(HANDLE,DWORD,DWORD,DWORD,DWORD,BOOL);
WINBASEAPI DWORD_PTR WINAPI SetThreadAffinityMask(HANDLE,DWORD_PTR); WINBASEAPI DWORD_PTR WINAPI SetThreadAffinityMask(HANDLE,DWORD_PTR);
WINBASEAPI BOOL WINAPI SetThreadContext(HANDLE,const CONTEXT *); WINBASEAPI BOOL WINAPI SetThreadContext(HANDLE,const CONTEXT *);
WINBASEAPI BOOL WINAPI SetThreadErrorMode(DWORD,LPDWORD);
WINBASEAPI DWORD WINAPI SetThreadExecutionState(EXECUTION_STATE); WINBASEAPI DWORD WINAPI SetThreadExecutionState(EXECUTION_STATE);
WINBASEAPI DWORD WINAPI SetThreadIdealProcessor(HANDLE,DWORD); WINBASEAPI DWORD WINAPI SetThreadIdealProcessor(HANDLE,DWORD);
WINBASEAPI BOOL WINAPI SetThreadPriority(HANDLE,INT); WINBASEAPI BOOL WINAPI SetThreadPriority(HANDLE,INT);