我得到Spotify的窗口標題我現在播放插件與功能:替換字符 uFFFD而GetWindowText函數(C代碼)
GetWindowText(spotify_window_handle, title, title_length)
但輸出包含替換字符\ uFFFD。
Ex. Spotify - Killswitch Engage � One Last Sunset
如何用C代替 ?
下面全碼:
char* spotify_title(int window_handle)
{
int title_length = GetWindowTextLength(window_handle);
if(title_length != 0)
{
char* title;
title = (char*)malloc((++title_length) * sizeof *title);
if(title != NULL)
{
GetWindowText(window_handle, title, title_length);
if(strcmp(title, "Spotify") != 0)
{
return title;
}
else
{
return "Spotify is not playing anything right now. Type !botnext command to restart playback.";
}
}
else
{
printf("PLUGIN: Unable to allocate memory for title\n");
}
free(title);
}
else
{
printf("PLUGIN: Unable to get Spotify window title\n");
}
}
// End of Spotify get title function
如何'title'聲明? – alk
我已經粘貼了全部函數 –