在 VB.net 中将 ActiveDs.LargeInteger 转换为 Long?

发布于 2024-12-17 14:56:20 字数 391 浏览 1 评论 0原文

我正在尝试计算密码到期日期,大部分示例代码都是 C# 中的

一个示例:

IADsLargeInteger largeInt;
largeInt = (IADsLargeInteger) largeIntVal;   
myLong = (long)largeInt.HighPart << 32 | (uint)largeInt.LowPart;

如果我在 VB.net 中尝试类似的操作:

dim myLong as Long
myLong = largeInt.HighPart << 32 Or largeInt.LowPart

那么我似乎会得到一个无效值。如何在VB中获得类似的结果?

I'm trying to compute the password expiry date, and most of the example code is in C#

One sample has:

IADsLargeInteger largeInt;
largeInt = (IADsLargeInteger) largeIntVal;   
myLong = (long)largeInt.HighPart << 32 | (uint)largeInt.LowPart;

If I try something similar in VB.net:

dim myLong as Long
myLong = largeInt.HighPart << 32 Or largeInt.LowPart

Then I seem to get an invalid value. How can I obtain similar results in VB?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宣告ˉ结束 2024-12-24 14:56:20

根据 this ,问题是因为 VB.Net 没有无符号整数类。

解决办法是:

props = resultDE.Properties("pwdLastSet")
Dim prop As ActiveDs.LargeInteger
prop = props(0)

Dim int64Value As Long
Dim strTemp As String
strTemp = "&H" + CStr(Hex(prop.HighPart)) + CStr(Hex(prop.LowPart))
int64Value = Val(strTemp)

According to this the problem is because VB.Net has no unsigned integer class.

The solution is:

props = resultDE.Properties("pwdLastSet")
Dim prop As ActiveDs.LargeInteger
prop = props(0)

Dim int64Value As Long
Dim strTemp As String
strTemp = "&H" + CStr(Hex(prop.HighPart)) + CStr(Hex(prop.LowPart))
int64Value = Val(strTemp)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文