Reading Shakespeare's play within the context of the demonologies available in English at the time it was written should lead to a few conclusions regarding the issue of the nature of ghosts.
1. Hamlet takes place in a Protestant world. In fact, it is both Protestant and English, despite the fact that the play is set in a slightly mythologized Denmark.
2. Hamlet, and his Wittenberg classmate, Horatio, subscribe to the popular notion of the time that the ghost is the manifestation of a demonic or divine spirit.
3. English audiences at the beginning of the 17th Century would have probably expected the ghost to be an evil spirit.
As we see from the first encounter with the ghost, Hamlet is hoping to determine to his own satisfaction whether the ghost is demonic or divine in origin. As a test, he attempts to assess Claudius' guilt through the means of the play within the play. But there is a question whether this is an accurate test. For Elizabethan audiences, determining that Claudius did kill Hamlet's father does not necessarily mean that the ghost Hamlet has encountered is "an honest ghost." In effect, errors in Hamlet's logic could lead to his deception. The question that needs to be asked is "what criteria can be used to accurately determine whether the ghost is demonic or divine in nature?" Again, the demonologies can provide some assistance.