I'm working on a roguelike similar to nethack (a console game where the graphics are simply unicode characters). However, I have reached a barrier when trying to identify what character the cursor is on. Is the cursor positioned over the character that represents a pile of gold or a wall, etc.?

The ReadConsoleOutputCharacter API would seem to be what is required here, but there is something wrong with my declaration and/or my method of calling it, as I apparently am unbalancing the stack.

Does the .NET Framework provide an internal method equivalent to the above API call? If not, could someone provide me with assistance on getting the declaration and function call to work as intended?

    Structure COORD
        Dim x As Integer
        Dim y As Integer
    End Structure

    Declare Function ReadConsoleOutputCharacter Lib "kernel32" Alias "ReadConsoleOutputCharacterA" (ByVal hConsoleOutput As IntPtr, ByRef lpCharacter As String, ByVal nLength As Integer, dwReadCoord As COORD, lpNumberOfCharsRead As IntPtr) As Integer

        Dim chrX As Char = ""

        Dim xCoord As New COORD
        xCoord.x = 5
        xCoord.y = 5

        ReadConsoleOutputCharacter(Process.GetCurrentProcess().MainWindowHandle, chrX, 1, xCoord, 1)

The obvious solution would be, since I am writing the output in the first place, I could simply trap the data and maintain it all internally, but if there is a simple way to just grab the information from the console, I would stand to save myself a lot of extra work. Plus, now I'm rather determined to gain the experience of seeing this method through.

Any assistance would be greatly appreciated.