Release 961023
[wine/multimedia.git] / win32 / init.c
blob5fa1b3a63e88e69fc90c06daf42c08db277bc7f1
1 /*
2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 */
7 #include <string.h>
8 #include <stdio.h>
9 #include <unistd.h>
10 #include "windows.h"
11 #include "winerror.h"
12 #include "handle32.h"
13 #include "except.h"
14 #include "task.h"
15 #include "stddebug.h"
16 #define DEBUG_WIN32
17 #include "debug.h"
19 /* The global error value
21 int WIN32_LastError;
23 /*********************************************************************
24 * CloseHandle (KERNEL32.23)
26 BOOL CloseHandle(KERNEL_OBJECT *handle)
28 if(ValidateKernelObject(handle) != 0)
30 SetLastError(ERROR_INVALID_HANDLE);
31 return 0;
34 if (handle<0x1000) /* FIXME: hack */
35 return CloseFileHandle(handle);
36 switch(handle->magic)
38 case KERNEL_OBJECT_UNUSED:
39 SetLastError(ERROR_INVALID_HANDLE);
40 return 0;
41 /* FIXME
42 case KERNEL_OBJECT_FILE:
43 rc = CloseFileHandle((FILE_OBJECT *)handle);
44 break;
47 default:
48 dprintf_win32(stddeb, "CloseHandle: type %ld not implemented yet.\n",
49 handle->magic);
50 break;
53 ReleaseKernelObject(handle);
54 return 0;
57 /***********************************************************************
58 * GetModuleFileNameA (KERNEL32.235)
60 DWORD GetModuleFileNameA(HMODULE32 hModule, LPSTR lpFilename, DWORD nSize)
62 strcpy(lpFilename, "c:\\dummy");
63 return 8;
66 /***********************************************************************
67 * GetModuleHandle (KERNEL32.237)
69 HMODULE32 WIN32_GetModuleHandle(char *module)
71 HMODULE32 hModule;
73 dprintf_win32(stddeb, "GetModuleHandle: %s\n", module ? module : "NULL");
74 /* Freecell uses the result of GetModuleHandleA(0) as the hInstance in
75 all calls to e.g. CreateWindowEx. */
76 if (module == NULL) {
77 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
78 hModule = pTask->hInstance;
79 } else
80 hModule = GetModuleHandle(module);
81 dprintf_win32(stddeb, "GetModuleHandle: returning %d\n", hModule );
82 return hModule;
85 /***********************************************************************
86 * GetStartupInfoA (KERNEL32.273)
88 VOID GetStartupInfoA(LPSTARTUPINFO lpStartupInfo)
90 lpStartupInfo->cb = sizeof(STARTUPINFO);
91 lpStartupInfo->lpReserved = NULL;
92 lpStartupInfo->lpDesktop = "Desktop";
93 lpStartupInfo->lpTitle = "Title";
95 lpStartupInfo->cbReserved2 = 0;
96 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
97 lpStartupInfo->hStdInput = (HANDLE32)0;
98 lpStartupInfo->hStdOutput = (HANDLE32)1;
99 lpStartupInfo->hStdError = (HANDLE32)2;
102 /* Initialize whatever internal data structures we need.
104 * Returns 1 on success, 0 on failure.
106 int KERN32_Init(void)
108 #ifndef WINELIB
109 /* Initialize exception handling */
110 EXC_Init();
111 #endif
112 return 1;