HI
I have implemented some basic functions.Now I want to use the remote print screen, but there are some problems:
1,use viReadToFile ,the documents are only have 4096kb
2,use viRead,Program death
This is my VB.NET source with viReadToFile code:
Private Sub FSE_btnHDCP_Click(sender As Object, e As EventArgs) Handles FSE_btnHDCP.Click
status = viVPrintf(vi, "
YST:COMM:GPIB:RTER EOI" + vbCrLf, 0) '此命令更改分隔符。
status = viVPrintf(vi, ":HCOP
EV:LANG WMF" + vbCrLf, 0) '设置WMF格式
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 20000) '设置超时
status = viVPrintf(vi, ":HCOP
EST1 'MMEM'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:NAME 'C:\USER\DATA\FILE.WMF'" + vbCrLf, 0) '
status = viVPrintf(vi, ":HCOP" + vbCrLf, 0) '开始
status = viVPrintf(vi, ":MMEM:MSIS 'C’" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:CDIR '\USER\DATA\'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM
ATA? 'FILE.WMF'" + vbCrLf, 0) '
status = viRead(vi, strRes, 16, retCount)
Dim x As Integer = Val(Mid(strRes, 2, 1))
Dim y As Integer = Val(Mid(strRes, 3, x))
VI_txtOUT.Text = retCount
status = viVPrintf(vi, ":MMEM:MSIS 'C’" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:CDIR '\USER\DATA\'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM
ATA? 'FILE.WMF'" + vbCrLf, 0) '
status = viReadToFile(vi, "D:\YouName.WMF", x + y + 2, retCount) '最大4096,且写入不覆盖。
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 2000) '设置超时为默认2秒
End Sub
This is my VB.NET source with viRead code:
Private Sub FSE_btnHDCP_Click(sender As Object, e As EventArgs) Handles FSE_btnHDCP.Click
status = viVPrintf(vi, "
YST:COMM:GPIB:RTER EOI" + vbCrLf, 0) '此命令更改分隔符。
status = viVPrintf(vi, ":HCOP
EV:LANG WMF" + vbCrLf, 0) '设置WMF格式
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 20000) '设置超时
status = viVPrintf(vi, ":HCOP
EST1 'MMEM'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:NAME 'C:\USER\DATA\FILE.WMF'" + vbCrLf, 0) '
status = viVPrintf(vi, ":HCOP" + vbCrLf, 0) '开始
Threading.Thread.Sleep(2000)
status = viVPrintf(vi, ":MMEM:MSIS 'C’" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:CDIR '\USER\DATA\'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM
ATA? 'FILE.WMF'" + vbCrLf, 0) '
status = viRead(vi, strRes, 16, retCount)
Dim x As Integer = Val(Mid(strRes, 2, 1))
Dim y As Integer = Val(Mid(strRes, 3, x))
VI_txtOUT.Text = retCount
status = viVPrintf(vi, ":MMEM:MSIS 'C’" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM:CDIR '\USER\DATA\'" + vbCrLf, 0) '
status = viVPrintf(vi, ":MMEM
ATA? 'FILE.WMF'" + vbCrLf, 0) '
status = viRead(vi, strRes, x + y + 2, retCount) '太长时读出为空,容易卡死
If (status < VI_SUCCESS) Then
MsgBox(" Failed to read from the instrument! ")
End If
VI_txtOUT.Text = VI_txtOUT.Text & retCount
If strRes = “” Then
MsgBox(“nothing”)
Else
strRes = Mid(strRes, x + 3, y)
FileOpen(1, Application.StartupPath + "\YouName.WMF", OpenMode.Output) '输出文档
Print(1, strRes)
FileClose(1)
End If
status = viSetAttribute(vi, VI_ATTR_TMO_VALUE, 2000) '设置超时为默认2秒
End Sub
if use viVScanf or viVQueryf like:
status = viVScanf(vi, "%t", strRes)
status = viVQueryf(vi, ":MMEMATA? 'FILE.WMF'“ + vbCrLf, "%t", strRes)
Sometimes the result is empty, and sometimes the result is “#572676淄茪”