1

その間

GetWindowText(spotify_window_handle, title, title_length)

出力には置換文字が含まれます。

Spotify - Philip Glass � Glassworks Opening

「�」を「-」に置き換える必要があります。しばらく前にこの質問を投稿しましたが、コードを貼り付けることをやめたので、タイトルに wchar_t を使用したと思われるので答えますが、そうではありません。タイトルはchar*です。私は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
4

1 に答える 1