2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
21 /***********************************************************************
22 * GetModuleHandle (KERNEL32.237)
24 HMODULE32
WIN32_GetModuleHandleA(char *module
)
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. */
32 TDB
*pTask
= (TDB
*)GlobalLock16( GetCurrentTask() );
33 hModule
= pTask
->hInstance
;
35 hModule
= GetModuleHandle16(module
);
36 dprintf_win32(stddeb
, "GetModuleHandleA: returning %d\n", hModule
);
40 HMODULE32
WIN32_GetModuleHandleW(LPCWSTR module
)
43 LPSTR modulea
= HEAP_strdupWtoA( GetProcessHeap(), 0, module
);
44 hModule
= WIN32_GetModuleHandleA( modulea
);
45 HeapFree( GetProcessHeap(), 0, modulea
);
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)
88 GetComputerName32A(LPSTR name
,LPDWORD size
) {
89 if (-1==gethostname(name
,*size
))
91 *size
= lstrlen32A(name
);
95 /***********************************************************************
96 * GetComputerNameW (KERNEL32.166)
99 GetComputerName32W(LPWSTR name
,LPDWORD size
) {
100 LPSTR nameA
= (LPSTR
)xmalloc(*size
);
102 if (!GetComputerName32A(nameA
,size
)) {
106 lstrcpynAtoW(name
,nameA
,*size
);
108 /* FIXME : size correct? */
112 /***********************************************************************
113 * GetUserNameA [ADVAPI32.67]
115 BOOL32
GetUserName32A(LPSTR lpszName
, LPDWORD lpSize
)
121 len
= name
? strlen(name
) : 0;
122 if (!len
|| !lpSize
|| len
> *lpSize
) {
123 if (lpszName
) *lpszName
= 0;
127 strcpy(lpszName
, name
);
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
);