473,480 Members | 3,069 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Importants of IntPtr?

??????????????????
What is the importance of IntPtr besides being, behind the scenes, a void
ptr, that gets cast into either an int* or an long* depending on the result
of sizeof(void*);
??????????????????
Oct 3 '07 #1
5 1250
TheMadHatter wrote:
??????????????????
What is the importance of IntPtr besides being, behind the scenes, a void
ptr, that gets cast into either an int* or an long* depending on the result
of sizeof(void*);
??????????????????
It is an extremely important type if you are mixing managed
and native code.

(and I assume you did not intend the asterisks in int* and long*)

Arne
Oct 4 '07 #2
Yes quite right, no asterisks.

But still....
If one uses the constructor:
public IntPtr (long i64)

It is still limited to the min and max of the Int32. ?

Why is the IntPtr important in interpolation? what about a void*?

I have seen a few P/Invokes use void* and some other sites use
a simular signature using IntPtr. (Dont ask me for the exact routine.
I dont remember, but at the time I was confused as to which one to
use.)

How is it that IntPtr is useful for COM?

"Arne Vajhøj" wrote:
TheMadHatter wrote:
??????????????????
What is the importance of IntPtr besides being, behind the scenes, a void
ptr, that gets cast into either an int* or an long* depending on the result
of sizeof(void*);
??????????????????

It is an extremely important type if you are mixing managed
and native code.

(and I assume you did not intend the asterisks in int* and long*)

Arne
Oct 4 '07 #3
>But still....
>If one uses the constructor:
public IntPtr (long i64)

It is still limited to the min and max of the Int32. ?
If you're on a 32-bit system, yes.

>Why is the IntPtr important in interpolation? what about a void*?

I have seen a few P/Invokes use void* and some other sites use
a simular signature using IntPtr. (Dont ask me for the exact routine.
I dont remember, but at the time I was confused as to which one to
use.)
It's mostly a matter of whether you want to use unsafe code in C# or
not. IntPtr can be used from "safe" code.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 4 '07 #4
TheMadHatter wrote:
"Arne Vajhøj" wrote:
>TheMadHatter wrote:
>>??????????????????
What is the importance of IntPtr besides being, behind the scenes, a void
ptr, that gets cast into either an int* or an long* depending on the result
of sizeof(void*);
??????????????????
It is an extremely important type if you are mixing managed
and native code.
If one uses the constructor:
public IntPtr (long i64)

It is still limited to the min and max of the Int32. ?
Only if it is 32 bit Windows.
Why is the IntPtr important in interpolation? what about a void*?

I have seen a few P/Invokes use void* and some other sites use
a simular signature using IntPtr. (Dont ask me for the exact routine.
I dont remember, but at the time I was confused as to which one to
use.)
You can use IntPtr in safe code via some classes (Marshal).
How is it that IntPtr is useful for COM?
I do not think it is.

COM objects can be used dierctly in .NET (or more correctly: .NET
provides the necesarry glue).

Arne
Oct 4 '07 #5
"TheMadHatter" <Th**********@discussions.microsoft.comwrote in message
news:44**********************************@microsof t.com...
Yes quite right, no asterisks.

But still....
If one uses the constructor:
public IntPtr (long i64)

It is still limited to the min and max of the Int32. ?

Why is the IntPtr important in interpolation? what about a void*?

I have seen a few P/Invokes use void* and some other sites use
a simular signature using IntPtr. (Dont ask me for the exact routine.
I dont remember, but at the time I was confused as to which one to
use.)

How is it that IntPtr is useful for COM?
Intptr is used in COM when you have to deal with custom marshaling.
In one word, IntPtr is important whenever you have to deal with native
pointers to opaque types.

Willy.
Oct 4 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
31242
by: Nuno Esculcas | last post by:
Hello, I come from C++ and i now have to work with C#, and someone tell me that bye bye pointers but i think this is not true, i must convert a DIB image in something that i can use in C# (like...
13
7380
by: Christian Westerlund | last post by:
Hi! I'm trying to use P/Invoke and a Method which takes an IntPtr where I am supposed to put an address to a method which the native method will use to communicate back to me. How do I convert a...
10
4603
by: Tamir Khason | last post by:
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, but in C# I recieve an error "Cannot...
2
6856
by: Alex Sedow | last post by:
Why explicit conversion from SomeType* to IntPtr is not ambiguous (according to standart)? Example: // System.IntPtr class IntPtr { public static explicit System.IntPtr (int); public...
6
1543
by: active | last post by:
I downloaded the Win32 Library which saved me MUCH work. Some (All?) of the returned handles are typed int. As I used them I often changed them in my copy of win32 to IntPtr because an...
0
3922
by: Jørn Jensen | last post by:
Hey! I have an issue with creating bitmap from an IntPtr. The IntPtr is created from a Twain scanner, which seem to work perfectly in it's original state (the app is originally written by somebody...
9
6174
by: pigeonrandle | last post by:
Hi, I'm trying to convert the following line to c# from VB6 If hrRapiInit >= 0 Then 'SUCCEEDED where hrRapiInit is declared as a Long. In c#, hrRapiInit must be declared as an IntPtr to fit...
1
4188
by: dcurington | last post by:
I have to call a function. This is from the SDK: INT is_GetActSeqBuf (HIDS hf, INT* pnNum, char** ppcMem, char** ppcMemLast); I have demo C# code that works. Here is the prototype: private...
0
2094
by: Charming12 | last post by:
Hi All, I have a strange problem and due to my inefficiency with IntPtr i am unable to figure it out. I have an structure something like: public struct Detail { public int age; public...
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
206
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.