SendNActionRequest Example for VB.NET

'LEADDICOMNet1 is a predefined LEADDicomNet object
'LEADDICOM1 is a DICOM Dataset defined outside this method
Private Sub TestSendNActionRequest ( )
   'this sample shows how to send an N-ACTION-REQUEST
   Const UID_BASIC_FILM_BOX_CLASS As String = "1.2.840.10008.5.1.1.2"
   ' Basic Film Box SOP Class
   Dim nRet As Short
   Dim szClassUID As String
   Dim szInstance As String
   Dim nVR As Short
   Dim hPDU As Integer
   Dim nID As Short
   Dim nAction As Short
   'send an N-ACTION-REQUEST to the server
   nAction = CShort(InputBox("What Action(1..10)?", "Action Request", CStr(1)))
   szClassUID = InputBox("What class?", "Action Request", UID_BASIC_FILM_BOX_CLASS)
   If (Len(szClassUID) < 1) Then Exit Sub
   szInstance = InputBox("What instance?", "Action Request", "1.1.1.1")
   If (Len(szInstance) < 1) Then Exit Sub
   'here you would create a data set that encodes the Action Arguments 'for this example, we just load a dataset
   '...
   nRet = LEADDICOM1.LoadDS("e:\images\dicom16.dic", 0)
   hPDU = LEADDICOMNet1.GetAssociate(LEADDICOMNet1.hNet)
   'now, send a request
   nID = LEADDICOMNet1.FindPresentationAbstract(hPDU, szClassUID)
   If (nID = 0) Then
      nRet = LEADDICOM1.FindUID(szClassUID)
      If (nRet = 0) Then
         MessageBox.Show("Abstract Syntax, " & LEADDICOM1.CurrentUID.Name & ", Not Supported by Association!")
      Else
         MessageBox.Show("Abstract Syntax, " & szClassUID & ", Not Supported by Association!")
      End If
      Exit Sub
   End If
   LEADDICOMNet1.SendNActionRequest(LEADDICOMNet1.hNet, nID, 1, szClassUID, szInstance, nAction, LEADDICOM1.hDicomDS)
End Sub