Release 970509
[wine/multimedia.git] / win32 / init.c
blobddd5799eab31b63c2a3ff25f8da2619df4ec0671
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 <stdlib.h>
11 #include "windows.h"
12 #include "winerror.h"
13 #include "handle32.h"
14 #include "except.h"
15 #include "heap.h"
16 #include "task.h"
17 #include "stddebug.h"
18 #include "debug.h"
19 #include "xmalloc.h"
21 /***********************************************************************
22 * GetModuleHandle (KERNEL32.237)
24 HMODULE32 WIN32_GetModuleHandleA(char *module)
26 HMODULE32 hModule;
28 dprintf_win32(stddeb, "GetModuleHandleA: %s\n", module ? module : "NULL");
29 /* Freecell uses the result of GetModuleHandleA(0) as the hInstance in
30 all calls to e.g. CreateWindowEx. */
31 if (module == NULL) {
32 TDB *pTask = (TDB *)GlobalLock16( GetCurrentTask() );
33 hModule = pTask->hInstance;
34 } else
35 hModule = GetModuleHandle16(module);
36 dprintf_win32(stddeb, "GetModuleHandleA: returning %d\n", hModule );
37 return hModule;
40 HMODULE32 WIN32_GetModuleHandleW(LPCWSTR module)
42 HMODULE32 hModule;
43 LPSTR modulea = HEAP_strdupWtoA( GetProcessHeap(), 0, module );
44 hModule = WIN32_GetModuleHandleA( modulea );
45 HeapFree( GetProcessHeap(), 0, modulea );
46 return hModule;
50 /***********************************************************************
51 * GetStartupInfoA (KERNEL32.273)
53 VOID GetStartupInfo32A(LPSTARTUPINFO32A lpStartupInfo)
55 lpStartupInfo->cb = sizeof(STARTUPINFO32A);
56 lpStartupInfo->lpReserved = "<Reserved>";
57 lpStartupInfo->lpDesktop = "Desktop";
58 lpStartupInfo->lpTitle = "Title";
60 lpStartupInfo->cbReserved2 = 0;
61 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
62 lpStartupInfo->hStdInput = (HANDLE32)0;
63 lpStartupInfo->hStdOutput = (HANDLE32)1;
64 lpStartupInfo->hStdError = (HANDLE32)2;
67 /***********************************************************************
68 * GetStartupInfoW (KERNEL32.274)
70 VOID GetStartupInfo32W(LPSTARTUPINFO32W lpStartupInfo)
72 lpStartupInfo->cb = sizeof(STARTUPINFO32W);
73 lpStartupInfo->lpReserved = HEAP_strdupAtoW(GetProcessHeap(),0,"<Reserved>");
74 lpStartupInfo->lpDesktop = HEAP_strdupAtoW(GetProcessHeap(), 0, "Desktop");
75 lpStartupInfo->lpTitle = HEAP_strdupAtoW(GetProcessHeap(), 0, "Title");
77 lpStartupInfo->cbReserved2 = 0;
78 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
79 lpStartupInfo->hStdInput = (HANDLE32)0;
80 lpStartupInfo->hStdOutput = (HANDLE32)1;
81 lpStartupInfo->hStdError = (HANDLE32)2;
84 /***********************************************************************
85 * GetComputerNameA (KERNEL32.165)
87 BOOL32
88 GetComputerName32A(LPSTR name,LPDWORD size) {
89 if (-1==gethostname(name,*size))
90 return FALSE;
91 *size = lstrlen32A(name);
92 return TRUE;
95 /***********************************************************************
96 * GetComputerNameW (KERNEL32.166)
98 BOOL32
99 GetComputerName32W(LPWSTR name,LPDWORD size) {
100 LPSTR nameA = (LPSTR)xmalloc(*size);
102 if (!GetComputerName32A(nameA,size)) {
103 free(nameA);
104 return FALSE;
106 lstrcpynAtoW(name,nameA,*size);
107 free(nameA);
108 /* FIXME : size correct? */
109 return TRUE;
112 /***********************************************************************
113 * GetUserNameA [ADVAPI32.67]
115 BOOL32 GetUserName32A(LPSTR lpszName, LPDWORD lpSize)
117 size_t len;
118 char *name;
120 name=getlogin();
121 len = name ? strlen(name) : 0;
122 if (!len || !lpSize || len > *lpSize) {
123 if (lpszName) *lpszName = 0;
124 return 0;
126 *lpSize=len;
127 strcpy(lpszName, name);
128 return 1;
131 /***********************************************************************
132 * GetUserNameW [ADVAPI32.68]
134 BOOL32 GetUserName32W(LPWSTR lpszName, LPDWORD lpSize)
136 LPSTR name = (LPSTR)xmalloc(*lpSize);
137 DWORD size = *lpSize;
138 BOOL32 res = GetUserName32A(name,lpSize);
140 lstrcpynAtoW(lpszName,name,size);
141 return res;