mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
don't expect set/get title symbols are always there
This commit is contained in:
parent
d092cb6e8e
commit
eb5dfedb6b
@ -109,6 +109,8 @@ extern char** environ;
|
||||
static char windows_error_details[64];
|
||||
static char ps_buffer[MAX_PATH];
|
||||
static const size_t ps_buffer_size = MAX_PATH;
|
||||
typedef BOOL (WINAPI *MySetConsoleTitle)(LPCTSTR);
|
||||
typedef DWORD (WINAPI *MyGetConsoleTitle)(LPTSTR, DWORD);
|
||||
#elif defined(PS_USE_CLOBBER_ARGV)
|
||||
static char *ps_buffer; /* will point to argv area */
|
||||
static size_t ps_buffer_size; /* space determined at run time */
|
||||
@ -367,8 +369,22 @@ int set_ps_title(const char* title)
|
||||
|
||||
#ifdef PS_USE_WIN32
|
||||
{
|
||||
if (!SetConsoleTitle(ps_buffer))
|
||||
MySetConsoleTitle set_title = NULL;
|
||||
HMODULE hMod = LoadLibrary("kernel32.dll");
|
||||
|
||||
if (!hMod) {
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
}
|
||||
|
||||
/* NOTE we don't use _UNICODE*/
|
||||
set_title = (MySetConsoleTitle)GetProcAddress(hMod, "SetConsoleTitleA");
|
||||
if (!set_title) {
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
}
|
||||
|
||||
if (!set_title(ps_buffer)) {
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
}
|
||||
}
|
||||
#endif /* PS_USE_WIN32 */
|
||||
|
||||
@ -388,8 +404,24 @@ int get_ps_title(int *displen, const char** string)
|
||||
return rc;
|
||||
|
||||
#ifdef PS_USE_WIN32
|
||||
if (!(ps_buffer_cur_len = GetConsoleTitle(ps_buffer, (DWORD)ps_buffer_size)))
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
{
|
||||
MyGetConsoleTitle get_title = NULL;
|
||||
HMODULE hMod = LoadLibrary("kernel32.dll");
|
||||
|
||||
if (!hMod) {
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
}
|
||||
|
||||
/* NOTE we don't use _UNICODE*/
|
||||
get_title = (MyGetConsoleTitle)GetProcAddress(hMod, "GetConsoleTitleA");
|
||||
if (!get_title) {
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
}
|
||||
|
||||
if (!(ps_buffer_cur_len = get_title(ps_buffer, (DWORD)ps_buffer_size))) {
|
||||
return PS_TITLE_WINDOWS_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*displen = (int)ps_buffer_cur_len;
|
||||
*string = ps_buffer;
|
||||
|
Loading…
Reference in New Issue
Block a user