LoadDSArray Example for Visual Basic
Private Sub TestLoadDSArray()
Dim FileName As String
Dim FileSize
Dim Ret As Integer
Dim factory As New LEADDicomFactory
Dim kernel As LEADDicomKernel
Dim szLic As String
Dim szClass As String
'These two variables should have the same scope
Dim LeadDicomDS As LeadDicomDS
Dim DataBuffer() As Byte
'Create the DICOM kernel object and unlock support
szLic = "LEADTOOLS OCX Copyright (c) 1991-2005 LEAD
Technologies, Inc."
Set kernel = factory.CreateObject("LEADDicomKernel.LEADDicomKernel",
szLic)
kernel.EnableMethodErrors =
False
'Make sure to replace L_KEY_MEDICAL with your key
kernel.UnlockSupport L_SUPPORT_MEDICAL,
L_KEY_MEDICAL
If (kernel.IsSupportLocked(L_SUPPORT_DICOM))
Then
MsgBox "Unlock Failed!"
Exit Sub
End If
'Create the DICOM dataset object
Set LeadDicomDS = factory.CreateObject("LEADDicomDS.LEADDicomDS",
szLic)
LeadDicomDS.EnableMethodErrors =
False
'We will simulate loading from array by reading a
'physical DICOM file into a byte array and then loading
it
FileName = "D:\Program Files\LEAD Technologies,
Inc\LEADTOOLS14\Images\IMAGE2.dic"
'File length
FileSize = FileLen(FileName)
If FileSize = 0 Then
Exit Sub
End If
'Allocate a buffer to hold the file data
ReDim DataBuffer(FileSize)
'Open the file in binary mode
Open FileName For Binary Access Read As #1
Get #1, , DataBuffer
'Load DICOM file from byte array
Ret = LeadDicomDS.LoadDSArray(DataBuffer,
0)
If Ret <> DICOM_SUCCESS Then
MsgBox "Error " & CStr(Ret)
& " loading file!"
End If
Close #1
'Get the info about this DICOM dataset
LeadDicomDS.GetInfoDS
LeadDicomDS.FindClassIOD LeadDicomDS.InfoClass
szClass = LeadDicomDS.CurrentIOD.Name
MsgBox "Class: " & szClass
End Sub