如何使用Int64创建IntPtr? [英] How can I create an IntPtr with an Int64?
问题描述
我正在尝试创建这样的IntPtr:
Dim pid 作为 新 IntPtr (< span class =code-sdkkeyword> Int64 .MaxValue)
等效的C#类似于:
IntPtr pid = new IntPtr ( Int64 .MaxValue);
我一直收到错误OverflowException。
我怎样才能做到这一点?
编辑:
这是用AnyCPU编译的。它是使用.NET CF 2.0的设备应用程序;目标设备正在运行Windows Mobile 6.5
您好b $ b试试这个..
IntPtr pid = new IntPtr ( int .MaxValue);
IntPtr类型设计为整数,其大小为特定于平台
。也就是说,这种类型的实例预计在32位硬件和操作系统上32位
,并且64位上的64位位硬件和操作系统
。
希望您的机器是32位操作系统。
参考: intptr [ ^ ]
在Visual Studio的对象浏览器中,当你转到IntPtr(long)
,然后你会看到以下例外
对象浏览器System.OverflowException:在32位平台上,值太大或太小而无法表示为System.IntPtr。
我猜你是在32位平台上运行你的应用程序,所以你得到这个错误。
I am trying to create an IntPtr like this:
Dim pid As New IntPtr(Int64.MaxValue)
The C# equivalent would be something like:
IntPtr pid = new IntPtr(Int64.MaxValue);
I keep getting the error "OverflowException".
How can I make this work?
edit:
This is being compiled with "AnyCPU". It's a device application using .NET CF 2.0; The target device is running Windows Mobile 6.5解决方案Hi try this..
IntPtr pid = new IntPtr(int.MaxValue);
The IntPtr type is designed to be an integer whose size isplatform-specific
. That is, an instance of this type is expected to be32-bits on 32-bit hardware and operating systems
, and64-bits on 64-bit hardware and operating systems
.
hope your machine is 32 bit operating system.
reference: intptr[^]
In the Object Browser of Visual Studio, when you go toIntPtr(long)
, then you see the following underExceptions
Object BrowserSystem.OverflowException: On a 32-bit platform, value is too large or too small to represent as an System.IntPtr.
I guess you are running your application on a 32-bit platform, so you get this error.
这篇关于如何使用Int64创建IntPtr?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!