By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,376 Members | 3,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,376 IT Pros & Developers. It's quick & easy.

problem in inpout32.dll

P: 49
hi,
i make project control by parallel port, to make that i added file called inpout32.dll to system folder in windows folder but when i went to my project and make add reference error message appear and tell me(c cannot added reference and make sure that the file is accessible and that is avalid assembly or com component)
how can i solve this problem.
Feb 10 '09 #1
Share this Question
Share on Google+
6 Replies


vekipeki
Expert 100+
P: 229
Inpout32.dll in an unmanaged dll. It is not an assembly, and it is not a COM component.

To use unmanaged APIs from .NET you will have to use P/Invoke. This means that you have to add your function signatures manually:

Expand|Select|Wrap|Line Numbers
  1. [DllImport("inpout32.dll", EntryPoint="Out32")]
  2. public static extern void Output(int adress, int value);
  3.  
Google for "inpout32.dll c#" and you will find several examples.
Feb 11 '09 #2

P: 49
hi
i want to ask another question
i want to use kbhit function in c#
to make control by pc.
how can i declared it ?
thanks
Feb 11 '09 #3

100+
P: 344
Hi,
If you use windows forms you can add event handler to the form's events, keydown, keyup, keypressed... etc.
1) Right click on the form -> Properties
2) Select events (small icon) from properties explorer
3) Double click on any event you want to make an event handler for it, it'll make the event handler method in the code behind, impelement it as you want.
Feb 11 '09 #4

P: 49
Hi,
i use windows form app,i made what you said,but i want to execute some instruction when i press keyboard so i need function to tell me if keyboard pressed or not,what is this function??
this is the code i wrote it in form _keypress


private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (KeyPress ==1)
{
int n;
switch (n)
{
case 0:
accessport.Output(888, 0);
break;
case 1:
accessport.Output(888, 1);
break;
case 2:
accessport.Output(888, 2);
break;
case 3:
accessport.Output(888, 3);
break;
case 4:
accessport.Output(888, 4);
break;
case 5:
accessport.Output(888, 5);
break;
case 6:
accessport.Output(888, 6);
break;
case 7:
accessport.Output(888, 7);
break;
case 8:
accessport.Output(888, 8);
break;
case 9:
accessport.Output(888, 9);
break;
}


}
}
}
}
Feb 11 '09 #5

tlhintoq
Expert 2.5K+
P: 3,525
A) Please use [code] tags
B) Reacting to key presses is something I know has been covered here on Bytes many times as well as numerous other tutorials on the 'net. As someone starting out the burden is on you to do some research of your own, as well as some trial and error experimentation to learn.

The people here are happy to help when you have "hit a wall", but shouldn't be the first place you go... "Oh it didn't work, I'll get someone to tell me the answer." You need to take it upon yourself to read tutorials, books, on-line references and tear apart the source code of thousands of projects available. Reading through working source code by more experienced coders will teach you LOTS!
Feb 11 '09 #6

100+
P: 344
Hi,
What is KeyPress? looks like a field, but for what reason you use it.
Form1_KeyPress will not be executed until a key is pressed, so don't ask again about the key is pressed or not. I mean that I think
Expand|Select|Wrap|Line Numbers
  1. if (KeyPress ==1)
is redundant.
And
Expand|Select|Wrap|Line Numbers
  1. switch (n)
How n will has a value, execute this statement will make an exception to ocuurs.
If there is an error occurs
some trial and error experimentation to learn
As tlhintoq said.
Good Luck
Feb 13 '09 #7

Post your reply

Sign in to post your reply or Sign up for a free account.