How to call glSelectBuffer in Delphi correctly?

Hi!

I want to use glSelectBuffer routine in Delphi. Then tried some different ways:

CASE (1)

type
SBtype = array of Cardinal;
var
SB : SBtype;
{after some code}
SetLength(SB, 100);
glSelectBuffer(100,SB);

Compile Error: Incompatible types: ‘Array’ and ‘Cardinal’

CASE (2)

type
SBtype = array of Cardinal;
var
SB : SBtype;
LastErr : string
{after some code}
SetLength(SB, 100);
glSelectBuffer(100,@SB);
glRenderMode(GL_SELECT);
glInitNames;
glPushName(1);
glBegin(GL_QUADS);
LastErr := gluErrorString(glGetError);
{after some code}
glEnd;
glRenderMode(GL_RENDER);

Result: code can be compiled without error messages, but LastErr became “invalid operation” after the command:
glBegin(GL_QUADS);
I have tried to cut and paste the LastErr assignment to different places and found that it goes to “invalid operation” right after the glBegin command. I don’t know why. Don’t know if it is the problem of glSelectBuffer.

CASE (3)

type
SBtype = array [1…100] of Cardinal;
var
SB : SBtype;
{after some code}
glSelectBuffer(100,SB);

Compile Error: Incompatible types: ‘SBtype’ and ‘PGLuint’

CASE (4)

type
SBtype = array [1…100] of Cardinal;
var
SB : SBtype;
LastErr : string
{after some code}
glSelectBuffer(100,@SB);
glRenderMode(GL_SELECT);
glInitNames;
glPushName(1);
glBegin(GL_QUADS);
LastErr := gluErrorString(glGetError);
{after some code}
glEnd;
glRenderMode(GL_RENDER);

Result: similar to CASE (2)

Can you give me any idea to solve this problem? Any related ideas are appeciated

Thank you!