Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Drawing;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- public class PortAccessAPI
- {
- /// <summary>
- /// This method will be used to send the data out to the parallel port.
- /// </summary>
- /// <param name="adress">Address of the port to which the data needs to be sent.</param>
- /// <param name="value">Data that need to send out.</param>
- [DllImport("inpout32.dll", EntryPoint="Out32")]
- public static extern void Output(int address, int value);
- /// <summary>
- /// This method will be used to receive any data from the parallel port.
- /// </summary>
- /// <param name="address">Address of the port from which the data should be received.</param>
- /// <returns>Returns Integer read from the given port.</returns>
- [DllImport("inpout32.dll", EntryPoint = "Inp32")]
- public static extern int Input(int address);
- }
- partial class MainForm : Form
- {
- void Button1Click(object sender, EventArgs e)
- {
- int address = 888;
- int value = 24;
- PortAccessAPI.Output(address, value);
- value = PortAccessAPI.Input(address);
- label1.Text = Convert.ToString(value);
- }
- void MainFormLoad(object sender, EventArgs e)
- {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement