Problems with types. Why changes to __gc*?????????

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I am new in programming smart cards and I got an error in compiling that I cannnot manage to get rid of.
There is a function in the PCSC that is called "ScardEstablishContext"

I am calling this function as

SCARDCONTEXT hSC; //SCARDCONTEXT=unsigned long
hResult=ScardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hSC)

If a define hSC as an internal variable of a method and then insisde this method call ScardEstablishContext there is no problem and it works. The problem is that afterwards there are some more functions where I have to pass the parameter hSC.

So I want to define hSC as a private attribute of a class and then modify its value inside a function.
The problem with this is that I got the following compiling error:

error C2664: ScardEstablisContext can not convert SCARDCONTEXT__gc* to LPSCARDCONTEXT

It seems the compiler changes the type, although I defined the private attribute as I did when defining it as a local variable.
I have tried casting and defiining as unsigned long but nothing works. Also tried to define as __nogc unsigned long but no way. Please help me!!!!!!!! I really need to get over it!!!!!
 
Gueverson,
Hello, I am new in programming smart cards and I got an error in compiling
that I cannnot manage to get rid of.
There is a function in the PCSC that is called "ScardEstablishContext"

I am calling this function as

SCARDCONTEXT hSC; //SCARDCONTEXT=unsigned long
hResult=ScardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hSC)


If a define hSC as an internal variable of a method and then insisde this
method call ScardEstablishContext there is no problem and it works. The
problem is that afterwards there are some more functions where I have to
pass the parameter hSC.
So I want to define hSC as a private attribute of a class and then modify its value inside a function.
The problem with this is that I got the following compiling error:

error C2664: ScardEstablisContext can not convert SCARDCONTEXT__gc* to LPSCARDCONTEXT

It seems the compiler changes the type, although I defined the private
attribute as I did when defining it as a local variable.
I have tried casting and defiining as unsigned long but nothing works.
Also tried to define as __nogc unsigned long but no way. Please help
me!!!!!!!! I really need to get over it!!!!!

It's not changing the type. It's exactly the same type as you declared it.
Since you declared the hSC as member of a __gc class, then it's pointer also
becomes __gc (since it's allocated in the managed heap). What you need to do
is pin your __gc object in memory before calling SCardEstablishContext().
 
hi,

"It's not changing the type. It's exactly the same type as you declared it.
Since you declared the hSC as member of a __gc class, then it's pointer also
becomes __gc (since it's allocated in the managed heap). What you need to do
is pin your __gc object in memory before calling SCardEstablishContext()."

how do you do that???

thx

From http://developmentnow.com/g/42_2004_2_0_0_154267/Problems-with-types-Why-changes-to--gc.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 
Back
Top