That is a very good question, which addresses the nature of the British Constitution. The Constitution is uncodified, which is to say that answers to constitutional questions must be drawn from a number of disparate sources. These include, principally, statute laws (such as the Bill of Rights, the Parliament Acts and, more recently, the Scotland Act and the Government of Wales Act), common law and case law (such as the House of Lords’ desision in Pepper v. Hart) and “custom and practice” or “precedent” (i.e. things which are done in a particular way because they have always been done this way). An example of the latter: the House of Lords will not block a Bill which enacts a manifesto committment of the governing party. (I think this is called the Ponsonby Rule). When, during debates in the House of Lords, peers have suggested blocking such bills (notwithstanding the recent debacle over the House of Lords Act), other peers have argued that they should not: an unelected Chamber should not block a proposal which the people had explicitly voted for. There is no legal rule to stop them from doing so, but the convention is fairly scrupulously observed and only in extreme or borderline cases would it be breached. It is a mistake to think of convention and precedent as somehow not really being an effective part of the British Constitution.
Appointment of PM
There are a number of situations in which the choice of Prime Minister is, to some extent at least, in the hands of the Monarch. The formation of the National Government after the collapse of the second Labour Government in 1931 is a good example. Likewise, the present Queen’s decision to accept Macmillan’s advice to appoint Home as his successor. Home was, at the time, not even a member of the House of Commons.
In practice, any Government needs the support of the House of Commons in order to govern. If the Queen were to appoint a PM who did not have that support, the Government would collapse within days.
Royal Assent
It is much more difficult to imagine the Queen refusing Royal Assent to a Act of Parliament passed in the proper manner by both Houses. Proponents of the Monarchy (I am not one of them) like to argue that the British Government could not do any real monstrosity–of the kind, for example, committed in Nazi Germany–because the Monarch, as guardian of the Constitution, would refuse Royal Assent to the necessary legislation. They may or may not be right (it is quite easy to imagine Edward VIII cozying up to the Nazis).
The point is that the Queen still retains the right to give or withold Royal Assent and, although it has not been exercised for a long time, that does not mean that there are no circumstances under which it might legitimately be exercised.
Dissolution of Parliament
I am paraphrasing here, because I do not have the book in front of me, but Peter Hennesy in his book, The Hidden Wiring, offers the following argument:
Imagine that a “lame duck” Tory Prime Minister has lost the confidence of her (or his) Party. A deeply disaffected senior backbencher and former Cabinet minister is threatening to run against her (or him) in a leadership contest. Her friends tell her that she cannot win and should either resign gracefully or “go down with all guns blazing” (© Alan Clark 1990). She has one last hope: that while she may have lost the confidence of her Party, she retains the confidence of the electorate. She goes to the Palace and asks for a dissolution.
Does the Queen grant a dissolution? No. It is only 2 or 3 years since the last general election, the Conservative party has a big enough majority for the present PM’s successor to continue to govern effectively and it would be wrong to put the interests of one politician ahead of those of the nation.
A far-fetched scenario, I know, but you could imagine it happening.
Conclusion
The short answer is: The Queen could legitimately exercise those powers under certain cirumstances and there are examples of the present Queen having done so. There are also, incidentally, examples of her Governors-General having done so in other countries (e.g. Gough Whitlam’s dismissal in Australia). It is a mistake to think of her powers as purely ceremonial (or “dignified”, to use Bagehot’s term) although it is fair to say that, in most cases, her decisions will be simply to approve whatever is put before her by the Cabinet and/or Parliament.