Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello all

I am using EPSON printer for passbook printing and barcode reading.

from many days i am trying to add the VC++ dll functionality(dll given by epson) to c# by help of one document,but i am not able to get it.

Now i am feeling i am going some where wrong.

Bwlow is one of the dll methods

DWORD WINAPI PrtOpen(LPCSTR lpszPortName)
Description:
The function opens the communication port.
Parameters:
lpszPortName is a string representing the name of the communication channel.
ex. "COM1", "USB001", "LPT1"
Return values:
PRT_SUCCESS if the port is not yet open and there are no errors.
PRT_ERR_ALREADY_OPEN if the port has already been opened with this function.


This is how i tried
C#
[DllImport(@"C:\Documents and Settings\Administrator\My Documents\visual studio 2010\Projects\TestClass\TestClass\PLQ20W32.dll", EntryPoint = "PrtBarRead")]
        private static extern string PrtOpen(string PortName);


But i am not able to make it work.

Please tell me the correct way to do it.
I have to finish my project soon.Please help.
Posted
Comments
[no name] 26-May-14 7:37am    
PrtOpen does not return a string.
[no name] 26-May-14 7:42am    
Please tell me the correct way to call it..
[no name] 26-May-14 7:46am    
Do you not know the difference between data types? Do you think that the DWORD being returned by PrtOpen is the same as a string in .NET?
[no name] 26-May-14 7:48am    
That's why i am asking that please tell me the correct way to call..i am going in a wrong way all to gather.
[no name] 26-May-14 8:24am    
Then I would suggest that you get a basic primer on programming and work through it. If you don't know the difference between an integer and a string then you are going to have nothing but trouble.

1 solution

Your definition seems wrong. use below definition and try again.

C#
[DllImport(@"C:\Documents and Settings\Administrator\My Documents\visual studio 2010\Projects\TestClass\TestClass\PLQ20W32.dll", EntryPoint = "PrtBarRead")]
        private static extern UInt32 PrtOpen(string PortName);
 
Share this answer
 
Comments
[no name] 26-May-14 11:06am    
Thanks..i will check and let u know..
[no name] 26-May-14 23:26pm    
I wrote the way u told, but when the control is coming to the method it's redirecting to the disassembly page..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900