ndra

Hi,
I want to develop an application for a RFID system. Basically for identification, e-wallet, etc. One of the problem is, the SDK for the equipment requires me to give the method a memory address for the var instead of the var itself for the response. They gave me an example in VB6, which they use VarPtr or IntPtr, and as far as i know C# doesn't have that (or is there... ). I tried to use the interop , but even though i can get the memory address then it changes the next time i check. Is there a method to call to put that var at static memory location


Re: Visual C# Language Var memory locations

Matthew Watson

There is an IntPtr type in C# (actually, it's a .Net type, and C# uses all .Net types).

It is used with p/invoke stuff, so you're on the right track.

What kind of variable are you passing to the SDK You will probably need to use the "fixed" keyword to prevent a managed object from being moved around in memory.




Re: Visual C# Language Var memory locations

Hugo

This should be trivial, post the API argument details and I'm sure many people here will assist.

If the API requies the address of (say) an Int32 then its as easy as this:

int my_arg;

my_external_api (ref my_arg);

if (my_arg....

This is really all you need to do, and you will not need to resort to "fixed" here UNLESS the argument is part of a managed object (which in this case it isnt, its unmanged stack data).

Regards

Hugh