Release 980301
[wine/hacks.git] / win32 / init.c
blob1472cc029fc4a086e50cf27e0d4e5e49612bd132
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 "except.h"
14 #include "heap.h"
15 #include "task.h"
16 #include "debug.h"
18 /***********************************************************************
19 * GetStartupInfoA (KERNEL32.273)
21 VOID WINAPI GetStartupInfo32A(LPSTARTUPINFO32A lpStartupInfo)
23 lpStartupInfo->cb = sizeof(STARTUPINFO32A);
24 lpStartupInfo->lpReserved = "<Reserved>";
25 lpStartupInfo->lpDesktop = "Desktop";
26 lpStartupInfo->lpTitle = "Title";
28 lpStartupInfo->cbReserved2 = 0;
29 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
30 lpStartupInfo->hStdInput = (HANDLE32)0;
31 lpStartupInfo->hStdOutput = (HANDLE32)1;
32 lpStartupInfo->hStdError = (HANDLE32)2;
35 /***********************************************************************
36 * GetStartupInfoW (KERNEL32.274)
38 VOID WINAPI GetStartupInfo32W(LPSTARTUPINFO32W lpStartupInfo)
40 lpStartupInfo->cb = sizeof(STARTUPINFO32W);
41 lpStartupInfo->lpReserved = HEAP_strdupAtoW(GetProcessHeap(),0,"<Reserved>");
42 lpStartupInfo->lpDesktop = HEAP_strdupAtoW(GetProcessHeap(), 0, "Desktop");
43 lpStartupInfo->lpTitle = HEAP_strdupAtoW(GetProcessHeap(), 0, "Title");
45 lpStartupInfo->cbReserved2 = 0;
46 lpStartupInfo->lpReserved2 = NULL; /* must be NULL for VC runtime */
47 lpStartupInfo->hStdInput = (HANDLE32)0;
48 lpStartupInfo->hStdOutput = (HANDLE32)1;
49 lpStartupInfo->hStdError = (HANDLE32)2;
52 /***********************************************************************
53 * GetComputerNameA (KERNEL32.165)
55 BOOL32 WINAPI GetComputerName32A(LPSTR name,LPDWORD size)
57 if (-1==gethostname(name,*size))
58 return FALSE;
59 *size = lstrlen32A(name);
60 return TRUE;
63 /***********************************************************************
64 * GetComputerNameW (KERNEL32.166)
66 BOOL32 WINAPI GetComputerName32W(LPWSTR name,LPDWORD size)
68 LPSTR nameA = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *size);
69 BOOL32 ret = GetComputerName32A(nameA,size);
70 if (ret) lstrcpynAtoW(name,nameA,*size);
71 HeapFree( GetProcessHeap(), 0, nameA );
72 /* FIXME : size correct? */
73 return ret;
76 /***********************************************************************
77 * GetUserNameA [ADVAPI32.67]
79 BOOL32 WINAPI GetUserName32A(LPSTR lpszName, LPDWORD lpSize)
81 size_t len;
82 char *name;
84 name=getlogin();
85 if (!name) name=cuserid(NULL);
86 len = name ? strlen(name) : 0;
87 if (!len || !lpSize || len > *lpSize) {
88 if (lpszName) *lpszName = 0;
89 return 0;
91 *lpSize=len;
92 strcpy(lpszName, name);
93 return 1;
96 /***********************************************************************
97 * GetUserNameW [ADVAPI32.68]
99 BOOL32 WINAPI GetUserName32W(LPWSTR lpszName, LPDWORD lpSize)
101 LPSTR name = (LPSTR)HeapAlloc( GetProcessHeap(), 0, *lpSize );
102 DWORD size = *lpSize;
103 BOOL32 res = GetUserName32A(name,lpSize);
105 lstrcpynAtoW(lpszName,name,size);
106 HeapFree( GetProcessHeap(), 0, name );
107 return res;