Add fake-api GetUserName

This commit is contained in:
Inori 2019-09-06 16:51:02 -04:00
parent 6fa65d8f93
commit 481f23eeef
4 changed files with 16 additions and 1 deletions

View file

@ -106,6 +106,7 @@ mkxp-z provides limited support for some WinAPI functions that would normally br
* `ReleaseCapture`: No-op.
* `GetPrivateProfileString`: Emulated with MKXP's ini code.
* `GetUserDefaultLangId`: Checks for JP, EN, FR, IT, DE, ES, KO, PT and ZH. Returns English (`0x09`) if the locale can't be determined. Doesn't handle sublanguages.
* `GetUserName`: Returns the `$USER` environment variable, or `Ditto` if it doesn't exist.
## Midi music

View file

@ -74,6 +74,7 @@ MiniFFI_GetFunctionHandle(void *libhandle, const char *func)
CAPTURE(ShowCursor);
CAPTURE(GetPrivateProfileString);
CAPTURE(GetUserDefaultLangID);
CAPTURE(GetUserName);
#endif
#endif
if (!libhandle) return 0;

View file

@ -460,4 +460,14 @@ MKXP_GetUserDefaultLangID(void)
return 0x09;
}
PREFABI BOOL
MKXP_GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer)
{
if (*pcbBuffer < 2) return false;
char *username = getenv("USER");
strncpy(lpBuffer, (username) ? username : "ditto", *pcbBuffer);
lpBuffer[0] = toupper(lpBuffer[0]);
return true;
}
#endif

View file

@ -13,7 +13,7 @@
#ifndef __WIN32__
typedef unsigned int DWORD, UINT, *LPDWORD;
typedef char BYTE, *LPCSTR, *LPCTSTR, *LPTSTR, *PBYTE;
typedef char BYTE, *LPSTR, *LPCSTR, *LPCTSTR, *LPTSTR, *PBYTE;
typedef short SHORT;
typedef int LONG;
typedef bool BOOL;
@ -147,4 +147,7 @@ MKXP_GetPrivateProfileString(LPCTSTR lpAppName,
PREFABI short
MKXP_GetUserDefaultLangID(void);
PREFABI BOOL
MKXP_GetUserName(LPSTR lpBuffer, LPDWORD pcbBuffer);
#endif