There's plenty of evidence that Hamlet knows from the start that his school friends Rosencrantz and Guildenstern can't be trusted. When he first sees them coming he says of the two, "These tedious old fools!"
So right off we know he's not all that fond of them. And after some pithy exchanges, Hamlet asks the duo:
But in the beaten way of friendship,
what make you at Elsinore?
To visit you, my lord; no other occasion.
Beggar that I am, I am even poor in thanks; but I
thank you; And sure, dear friends, my thanks are too dear
a halfpenny. Were you not sent for? Is it your own inclining?
Is it a free visitation? Come, deal justly with me.
Come, come! Nay, speak.
What should we say, my lord?
Why, anything, but to the purpose. You were sent
for; and there is a kind of confession in your looks, which
your modesties have not craft enough to colour. I know the
good King and Queen have sent for you.
He's on to them and none too pleased. With friends like that...
He finishes talking to them with this cutting little speech, which no doubt leaves them with open, silent mouths:
Why, look you now, how unworthy a thing you make of me! You would play upon me; you would seem to know my stops; you would pluck out the heart of my mystery; you would sound me from my lowest note to the top of my compass; and there is much music, excellent voice, in this little organ, yet cannot you make it speak. 'Sblood, do you think I am easier to be played on than a pipe? Call me what instrument you will, though you can fret me, you cannot play upon me.