Click here to Skip to main content
15,888,984 members
Home / Discussions / C#
   

C#

 
GeneralRe: Old famous problem. Access to Form1 from other namespace Pin
Pete O'Hanlon30-Oct-14 7:05
mvePete O'Hanlon30-Oct-14 7:05 
GeneralRe: Old famous problem. Access to Form1 from other namespace Pin
Member 1115157130-Oct-14 10:18
Member 1115157130-Oct-14 10:18 
AnswerRe: Old famous problem. Access to Form1 from other namespace Pin
OriginalGriff29-Oct-14 6:01
mveOriginalGriff29-Oct-14 6:01 
GeneralRe: Old famous problem. Access to Form1 from other namespace Pin
Member 1115157130-Oct-14 22:10
Member 1115157130-Oct-14 22:10 
QuestionBound DataGridView with unbound text box column Pin
Nigel Mackay28-Oct-14 23:54
Nigel Mackay28-Oct-14 23:54 
AnswerRe: Bound DataGridView with unbound text box column Pin
Eddy Vluggen29-Oct-14 9:51
professionalEddy Vluggen29-Oct-14 9:51 
GeneralRe: Bound DataGridView with unbound text box column Pin
Nigel Mackay29-Oct-14 15:42
Nigel Mackay29-Oct-14 15:42 
QuestionUnable to write to a parallel port Pin
Salman S7R28-Oct-14 20:12
Salman S7R28-Oct-14 20:12 
I am using c# to read and write my computer's parallel port. I am using a software named "winlpt" to manage it, and it works fine. Even I have attached an LED to my LPT1 port and it turns on if a use this software. But the issue I am facing is through programming. I am using inpout32.dll and also inpoutx64.dll but I can read my port using the address 888 but can not write to it with any value like 0 - 255 or even in binary form. My led do not lights up when I start my program. I have seen several samples on line all with similar code which I have and also downloaded any tried few of those demo projects but still not getting my led top anybody.

The c# code I am using:
PortInterop.cs file:

using System;
using System.Runtime.InteropServices;

public class PortAccess
{

[DllImport("inpout32.dll", EntryPoint = "Out32")]
public static extern void Output(int adress, int value);

[DllImport("inpout32.dll", EntryPoint = "Inp32")]
public static extern int Input(int adress);

}

Program.cs file (giving three different output values):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace leds
{
class Program
{
public static void Main(string[] args)
{
int address = 888;
int value;
value = PortAccess.Input(address);
Console.WriteLine("Input Value: " + value);
//FF or 255 D0-D7 on
PortAccess.Output(address, 255);
Console.WriteLine("\nOutput Value: 255");
Console.ReadLine();

//FF or 255 D0-D7 on
PortAccess.Output(address, 200);
Console.WriteLine("Output Value: 200");
Console.ReadLine();

//FF or 255 D0-D7 on
PortAccess.Output(address, 100);
Console.WriteLine("Output Value: 100");
Console.ReadLine();

//00 or 0 D0-D7 off
PortAccess.Output(address, 0);
Console.ReadLine();
}
}
}

And I am using windows 8.1, does it even works on win7++ OS?

Please help anybody.
Salman Malik


modified 29-Oct-14 8:41am.

AnswerRe: Unable to write to a parallel port Pin
Garth J Lancaster28-Oct-14 20:23
professionalGarth J Lancaster28-Oct-14 20:23 
GeneralRe: Unable to write to a parallel port Pin
Salman S7R28-Oct-14 20:28
Salman S7R28-Oct-14 20:28 
AnswerRe: Unable to write to a parallel port Pin
Garth J Lancaster28-Oct-14 20:28
professionalGarth J Lancaster28-Oct-14 20:28 
GeneralRe: Unable to write to a parallel port Pin
Salman S7R28-Oct-14 20:30
Salman S7R28-Oct-14 20:30 
GeneralRe: Unable to write to a parallel port Pin
Garth J Lancaster29-Oct-14 1:53
professionalGarth J Lancaster29-Oct-14 1:53 
QuestionSQL connection in the app.config file? Pin
Member 245846728-Oct-14 17:54
Member 245846728-Oct-14 17:54 
AnswerRe: SQL connection in the app.config file? Pin
V.28-Oct-14 20:58
professionalV.28-Oct-14 20:58 
QuestionRe: SQL connection in the app.config file? Pin
ZurdoDev29-Oct-14 3:35
professionalZurdoDev29-Oct-14 3:35 
GeneralRe: SQL connection in the app.config file? Pin
PIEBALDconsult29-Oct-14 4:12
mvePIEBALDconsult29-Oct-14 4:12 
AnswerRe: SQL connection in the app.config file? Pin
Simon_Whale29-Oct-14 5:38
Simon_Whale29-Oct-14 5:38 
AnswerRe: SQL connection in the app.config file? Pin
Gerry Schmitz29-Oct-14 10:45
mveGerry Schmitz29-Oct-14 10:45 
GeneralRe: SQL connection in the app.config file? Pin
Member 245846729-Oct-14 23:05
Member 245846729-Oct-14 23:05 
GeneralRe: SQL connection in the app.config file? Pin
Gerry Schmitz29-Oct-14 23:43
mveGerry Schmitz29-Oct-14 23:43 
GeneralRe: SQL connection in the app.config file? Pin
Member 245846730-Oct-14 16:29
Member 245846730-Oct-14 16:29 
GeneralRe: SQL connection in the app.config file? Pin
Gerry Schmitz30-Oct-14 21:00
mveGerry Schmitz30-Oct-14 21:00 
QuestionNot an asynchronous query(that just unblocks the calling thread) but an asynchronously *yielding* query Pin
Alaric_28-Oct-14 13:26
professionalAlaric_28-Oct-14 13:26 
AnswerRe: Not an asynchronous query(that just unblocks the calling thread) but an asynchronously *yielding* query Pin
Alaric_29-Oct-14 6:07
professionalAlaric_29-Oct-14 6:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.