如何在C#windows应用程序中使用VC ++代码 [英] How to use VC++ code in C# windows application

查看:103
本文介绍了如何在C#windows应用程序中使用VC ++代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello all



我使用EPSON打印机进行存折打印和条形码阅读。



来自很多天我试图通过一个文档的帮助将VC ++ dll功能(由epson给出的dll)添加到c#,但是我无法得到它。



现在我觉得我错了。



Bwlow是dll方法之一



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

[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.

推荐答案

你的定义似乎错了。使用下面的定义并再试一次。



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

[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);


这篇关于如何在C#windows应用程序中使用VC ++代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆