IADsLargeInteger 인터페이스(iads.h)

IADsLargeInteger 인터페이스는 LargeInteger 형식의 64비트 정수 조작에 사용됩니다.

상속

IADsLargeInteger 인터페이스는 IDispatch 인터페이스에서 상속됩니다.

설명

Visual Basic에서 IADsLargeInteger 를 처리하는 것은 Visual Basic에 서명되지 않은 네이티브 숫자 데이터 형식이 없다는 사실 때문에 어렵습니다. 이로 인해 LowPart 또는 HighPart에 높은 비트 집합이 있는 경우 데이터 변환에 오류가 발생할 수 있으므로 Visual Basic에서 숫자를 음수로 처리합니다. 아래 Visual Basic 코드 예제에서는 Visual Basic에서 IADsLargeInteger 를 올바르게 처리하는 방법을 보여 줍니다.

다음 예제에서는 IADsLargeInteger 개체를 16진수 문자열로 변환하는 방법을 보여 줍니다.

Dim oDomain As IADs
Dim oLargeInt As LargeInteger

Set oDomain = GetObject("LDAP://DC=fabrikam,DC=com")
Set oLargeInt = oDomain.Get("creationTime")

Debug.Print oLargeInt.HighPart
Debug.Print oLargeInt.LowPart

strTemp = "&H" + CStr(Hex(oLargeInt.HighPart)) + _
     CStr(Hex(oLargeInt.LowPart))
Debug.Print strTemp

Visual Basic에서는 FileTimeToSystemTimeSystemTimeToVariantTime API를 사용하여 날짜 및/또는 시간을 나타내는 IADsLargeInteger 개체를 time Variant로 변환할 수 있습니다. 다음 코드 예제에서 이를 확인할 수 있습니다.

Public Declare Function FileTimeToSystemTime Lib "kernel32" _
   (lpFileTime As FILETIME, _
   lpSystemTime As SYSTEMTIME) As Long

Public Declare Function SystemTimeToVariantTime Lib "oleaut32.dll" _
    (lpSystemTime As SYSTEMTIME, _
    dbTime As Double) As Long

Public Type SYSTEMTIME
    wYear As Integer
    wMonth As Integer
    wDayOfWeek As Integer
    wDay As Integer
    wHour As Integer
    wMinute As Integer
    wSecond As Integer
    wMilliseconds As Integer
End Type

Public Type FILETIME
    dwLowDateTime As Long
    dwHighDateTime As Long
End Type


' This function will convert the ADSI data type LargeInteger to
' a Variant time value in Greenwich Mean Time (GMT).
Function LargeInteger_To_Time(oLargeInt As LargeInteger, vTime As Variant)_
              As Boolean
    On Error Resume Next
    Dim pFileTime As FILETIME
    Dim pSysTime As SYSTEMTIME
    Dim dbTime As Double
    Dim lResult As Long
    
    If (oLargeInt.HighPart = 0 And oLargeInt.LowPart = 0) Then
        vTime = 0
        LargeInteger_To_Time = True
        Exit Function
    End If
    
    If (oLargeInt.LowPart = -1) Then
        vTime = -1
        LargeInteger_To_Time = True
        Exit Function
    End If
    
    pFileTime.dwHighDateTime = oLargeInt.HighPart
    pFileTime.dwLowDateTime = oLargeInt.LowPart
    
    ' Convert the FileTime to System time.
    lResult = FileTimeToSystemTime(pFileTime, pSysTime)
    If lResult = 0 Then
        LargeInteger_To_Time = False
        Debug.Print "FileTimeToSystemTime: " + Err.Number + "  - "_
                   + Err.Description
        Exit Function
    End If
    
    ' Convert System Time to a Double.
    lResult = SystemTimeToVariantTime(pSysTime, dbTime)
    If lResult = 0 Then
        LargeInteger_To_Time = False
        Debug.Print "SystemTimeToVariantTime: " + Err.Number + _
                 "  - " + Err.Description
        Exit Function
    End If
    
    ' Place the double in the variant.
    vTime = CDate(dbTime)
    LargeInteger_To_Time = True

End Function

다음 예제에서는 IADsLargeInteger 를 64비트 정수로 변환하는 방법을 보여 줍니다.

HRESULT PrintAccountExpires(LPCWSTR pwszADsPath)
{
    if(!pwszADsPath)
    {
        return E_INVALIDARG;
    }
    
    HRESULT hr;
    CComPtr<IADs> spads;

    // Bind to the object.
    hr = ADsGetObject(pwszADsPath, IID_IADs, (LPVOID*)&spads);
    if(FAILED(hr))
    {
        return hr;
    }

    /*
    Get the accountExpires attribute, which is an
    IDispatch that contains an IADsLargeInteger.
    */
    CComVariant svar;
    hr = spads->Get(CComBSTR("accountExpires"), &svar);
    if(FAILED(hr))
    {
        return hr;
    }

    // Get the IADsLargeInteger interface.
    CComPtr<IADsLargeInteger> spli;
    hr = svar.pdispVal->QueryInterface(IID_IADsLargeInteger, 
                                      (LPVOID*)&spli);
    if(FAILED(hr))
    {
        return hr;
    }

    // Get the high and low parts of the value.
    long lHigh;
    long lLow;
    hr = spli->get_HighPart(&lHigh);
    hr = spli->get_LowPart(&lLow);

    // Convert the high and low parts to an __i64.
    __int64 i64;
    i64 = (ULONG)lHigh;
    i64 = (i64 << 32);
    i64 = i64 + (ULONG)lLow;
    
    // Print all of the values.
    wprintf(L"HighPart = %u, LowPart = %u, Combined = %I64d\n", 
            lHigh, lLow, i64);

    return hr;
}

요구 사항

   
지원되는 최소 클라이언트 Windows Vista
지원되는 최소 서버 Windows Server 2008
대상 플랫폼 Windows
헤더 iads.h

추가 정보

IADsLargeInteger 속성 메서드

IDispatch