Partially implemented (handlers only)
[reactos.git] / reactos / lib / kernel32 / misc / error.c
1 /* $Id: error.c,v 1.13 2000/04/25 23:22:53 ea Exp $
2 *
3 * reactos/lib/kernel32/misc/error.c
4 *
5 */
6 #include <ddk/ntddk.h>
7 #include <ddk/ntddbeep.h>
8
9 // #define NDEBUG
10 #include <kernel32/kernel32.h>
11 #include <kernel32/error.h>
12
13
14 /* INTERNAL */
15 DWORD
16 STDCALL
17 SetLastErrorByStatus (
18 NTSTATUS Status
19 )
20 {
21 DWORD Error = RtlNtStatusToDosError (Status);
22 SetLastError (Error);
23 return (Error);
24 }
25
26
27 VOID
28 STDCALL
29 SetLastError (
30 DWORD dwErrorCode
31 )
32 {
33 NtCurrentTeb ()->LastErrorValue = (ULONG) dwErrorCode;
34 }
35
36 DWORD
37 STDCALL
38 GetLastError (VOID)
39 {
40 return (DWORD) (NtCurrentTeb ()->LastErrorValue);
41 }
42
43
44 BOOL
45 __ErrorReturnFalse (ULONG ErrorCode)
46 {
47 return(FALSE);
48 }
49
50
51 PVOID
52 __ErrorReturnNull (ULONG ErrorCode)
53 {
54 return(NULL);
55 }
56
57
58 WINBOOL
59 STDCALL
60 Beep (DWORD dwFreq, DWORD dwDuration)
61 {
62 HANDLE hBeep;
63 BEEP_SET_PARAMETERS BeepSetParameters;
64 DWORD dwReturned;
65
66 hBeep = CreateFile("\\\\.\\Beep",
67 FILE_GENERIC_READ | FILE_GENERIC_WRITE,
68 0,
69 NULL,
70 OPEN_EXISTING,
71 0,
72 NULL);
73 if (hBeep == INVALID_HANDLE_VALUE)
74 return FALSE;
75
76 /* Set beep data */
77 BeepSetParameters.Frequency = dwFreq;
78 BeepSetParameters.Duration = dwDuration;
79
80 DeviceIoControl(hBeep,
81 IOCTL_BEEP_SET,
82 &BeepSetParameters,
83 sizeof(BEEP_SET_PARAMETERS),
84 NULL,
85 0,
86 &dwReturned,
87 NULL);
88
89 CloseHandle (hBeep);
90
91 return TRUE;
92 }
93
94
95 /* EOF */