64位vb.net项目的数据类型 [英] datatype for 64bit vb.net project

查看:184
本文介绍了64位vb.net项目的数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旧的vb6项目.现在我在vs2008上的vb.net中迁移它,现在我必须使用64位解决方案平台.在旧代码中,变量hContext被声明为Integer.

I have a old vb6 project.Now I migrating it in vb.net on vs2008 and the solution plateform now I have to use 64bit.In the old code the variable hContext was declared as Integer.

Dim hContext As Integer



并用作



And used as

Dim rc As Integer
dwScope = SCARD_SCOPE_USER
rc = SCardEstablishContext(dwScope, 0, 0, hContext)



当我调试代码时,hContext创建问题.
这是因为它定义为Integer(32bit).
现在的问题是我应该为hContext使用哪种数据类型".我还使用了Long,ULong等不同的数据类型.



When I debug the code the hContext create problem.
This is due to it define as a Integer(32bit).
Now the problem is "What datatype should I use for hContext".I have also used different datatype like Long,ULong.

推荐答案

这是指针,所有指针都得到IntPtr的大小在32位系统上为32位,在64位系统上为64位,所有其他.NET类型都具有相同的大小,而与目标汇编的指令集体系结构无关.同样,最后一个参数为out类型也很重要.

因此,函数原型将声明为
This is pointer, and all pointers gets the size of IntPtr which is 32-bit on 32-bit systems and and 64-bits on 64-bit systems, all other .NET types have the same size regardless of the instruction-set architecture of target assembly. Also, it''s important that the last parameter is of out type.

So, the function prototype will be declared as
Private Shared Function SCardEstablishContext(scope As System.UInt32, reserved1 As System.IntPtr, reserved2 As System.IntPtr, ByRef context As System.IntPtr) As Long



—SA



—SA


从Microsoft API中,我们看到以下内容:

From the Microsoft API we see the following :

LONG WINAPI SCardEstablishContext(
  __in   DWORD dwScope,
  __in   LPCVOID pvReserved1,
  __in   LPCVOID pvReserved2,
  __out  LPSCARDCONTEXT phContext
);



如您所见,返回类型是long,在32位和64位系统上为8个字节.



As you can see the return type is a long which is 8 bytes on 32bit and 64bit systems.


这篇关于64位vb.net项目的数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆