Re: Indexing of IntPtr
From: Tamir Khason (tamir-NOSPAM_at_tcon-NOSPAM.co.il)
Date: 09/20/04
- Next message: jac: "exit asp-application"
- Previous message: Shiva: "Re: Repeater - rows"
- In reply to: Richard Blewett [DevelopMentor]: "Re: Indexing of IntPtr"
- Next in thread: Steven Cheng[MSFT]: "Re: Indexing of IntPtr"
- Reply: Steven Cheng[MSFT]: "Re: Indexing of IntPtr"
- Reply: Richard Blewett [DevelopMentor]: "Re: Indexing of IntPtr"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 20 Sep 2004 10:20:37 +0200
Almost, it's going like this:
[DllImport("Foo.dll")]
static extern IntPtr int_unmg_get_items(IntPtr raw);
public IntPtr Items {
get {
IntPtr ret = int_unmg_get_items (Handle);
return ret;
}
}
--
Tamir Khason
You want dot.NET? Just ask:
"Please, www.dotnet.us "
"Richard Blewett [DevelopMentor]" <richardb@develop.com> wrote in message
news:uvVMsxmnEHA.2764@TK2MSFTNGP11.phx.gbl...
> OK, so an interop call returns a pointer to an array which you receive as
> an IntPtr, e.g.:
>
> [DllImport("Foo.dll")]
>
> IntPtr GetArray();
>
> or something like that.
>
> Now in the class you have you want to provide access to this array via an
> indexer. However
>
> IntPtr i = GetArray();
>
> public char this[int index]
>
> {
>
> get
>
> {
>
> return i[index];
>
> }
>
> }
>
> doesn't compile?
>
> IntPtr is not mea';t to be manipulated from managed code only received and
> returned - as I explained. You need to receive this array back in a way in
> which you can manipulate not as an IntPtr.
>
> Have I got the scenario right? and if so can you show us the P/Invoke
> signature (DllImport, etc)
>
> regards
>
> Richard Blewett - DevelopMentor
>
> http://staff.develop.com/richardb/weblog
>
>
>
>
> nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/>
>
> As I mentioned earlier I build a function with return from unmanaged the
> pointer to array item on override of "this" method so when using Func[1]
> it
> will return the pointer to 1st member of source array, but (see message)
> an
> error on calling this function
>
>
>
> "Richard Blewett [DevelopMentor]" <richardb@develop.com> wrote in message
> news:OXMPlMmnEHA.3464@tk2msftngp13.phx.gbl...
> >I think you misunderstand the nature of IntPtr. It is mean't to be used
> >to
> >represent an opaque handle retrieved via interop - its not a pointer to
> >an
> >integer or a pointer of integer size. The point is its a "thing" that you
> >receive from and pass back to the interop layer (and so to the operating
> >system or some other DLL). if you want to walk a specific array just
> >index
> >into the array or use foreach.
> >
> > What exactly are you trying to achieve?
> >
> > Regards
> >
> > Richard Blewett - DevelopMentor
> >
> > http://staff.develop.com/richardb/weblog
> >
> >
> > nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/#G7Bt8lnEHA.2764@TK2MSFTNGP11.phx.gbl
>
> > I have a pointer to array and I want to apply indexing to this Array so
> > I
> > have function (name it IntPrt Func[]) to go to certain member I can use
> > (as
> > C++) Func[5], but in C# I recieve an error "Cannot apply indexing with
> > []
> > to
> > an expression of type 'System.IntPtr'".
> >
> > How to get rid of it?
> >
> > TNX
> >
> > --
> > Tamir Khason
> > You want dot.NET? Just ask:
> > "Please, www.dotnet.us "
> >
> >
> >
> > ---
> > Incoming mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004
> >
> >
> >
> > [microsoft.public.dotnet.languages.csharp]
>
>
>
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004
>
>
>
> [microsoft.public.dotnet.languages.csharp]
- Next message: jac: "exit asp-application"
- Previous message: Shiva: "Re: Repeater - rows"
- In reply to: Richard Blewett [DevelopMentor]: "Re: Indexing of IntPtr"
- Next in thread: Steven Cheng[MSFT]: "Re: Indexing of IntPtr"
- Reply: Steven Cheng[MSFT]: "Re: Indexing of IntPtr"
- Reply: Richard Blewett [DevelopMentor]: "Re: Indexing of IntPtr"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|