The following code clears the active playlist and adds the tracks (possibly more than one) referred to by the given URL to it. It creates an undo point, so the user can revert to the previous playlist content. The select parameter controls if the new tracks will be selected. The parent window argument is needed for an eventual progress window; do not pass NULL for this! (core_api::get_main_window is an appropriate choice, if you do not have a window of your own.)
// Not tested, but should work.
void finding_a_better_name_for_this_function_is_left_as_an_exercise_for_the_reader(const char *url, bool select, HWND parentwnd)
{
static_api_ptr_t<playlist_manager> pm;
t_size playlist = pm->get_active_playlist(); // Use a different playlist if desired.
pm->playlist_undo_backup(playlist); // Highly recommended unless you modify a locked, "smart" playlist (that you own)
pm->playlist_clear(playlist); // If you want to replace the existing playlist content.
pm->playlist_add_locations(
playlist,
pfc::list_single_ref_t<const char *>(url),
select,
parentwnd);
}