using System; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using NationalInstruments.VisaNS; // Add Reference->NationalInstruments.VisaNS & NationalInstruments.common by installing NI-VISA .NET4 files // Change Project Example Properties Applicaiton Target fromwork to ".Net Framework 4" namespace Example7_HardCopy { public partial class Form1 : Form { private MessageBasedSession mbSession; // Instrument VISA address string resourceString = "USB0::0x0699::0x03B2::QU010012::INSTR"; // Where to save string target_path = @"C:\temp\"; string target_name = @"TBS_screen.bmp"; byte[] Block = null; public Form1() { InitializeComponent(); // Open connection to instrument mbSession = (MessageBasedSession)ResourceManager.GetLocalManager().Open(resourceString); // Change timeout to 10 sec. mbSession.Timeout = 10000; // Copy Image HardCopy(); // Close instrument connection mbSession.Dispose(); } private void Form1_Load(object sender, EventArgs e) { } private void HardCopy() { // Send commands as described in programmers manual mbSession.Write("HardCopy:FormatException BMP"); mbSession.Write("Hardcopy:Layout Portrait"); mbSession.Write("Hardcopy:port USB"); mbSession.Write("Hardcopy Start"); // Read bytes Block = mbSession.ReadByteArray(); // Write bytes to file File.WriteAllBytes(target_path + target_name, Block); } } }