把你DLL的接口和C#中的声明写出来,这样才更容易获得帮助。
你的程式明天就要给用户那么着急真是替你的客户担心啊。
你的程式明天就要给用户那么着急真是替你的客户担心啊。
解决方案 »
- C# progressbar 如何实现加载图片显示进度
- VS2008数据库连接问题
- 数据库问题
- NHibernate问题,急!!!
- axWebBrowser打造浏览器的一些问题。搜索了Csdn和网上的一些文档,没找到解决方法。请大家帮忙。
- [调查]WinForm,财务系统 中,采用什么实现 财务报表??
- C# Socket编程问题求教,急!!!(服务器程序)
- 用Graphics.FillPie方法画椭圆,可不可以画成立体的
- 我想做个 资源管理器,请大家帮忙!
- C#如何作多UI线程?
- 在对webservice的引用中如何改变引用的服务器名称要设置变量吗?
- 为什么提示我DocumentNavaigator没有using进来?
_declspec(dllexport) int _stdcall GetDeviceInfo(HANDLE deviceHandle,char* deviceInfo)
{
BYTE WriteBuffer[5]; // 发送数据缓冲区
DWORD BytesWritten; // 发送字节数 BYTE ReadBuffer[17]; // 接收数据缓冲区
DWORD BytesRead; // 接收字节数
BYTE checkSum=0x0; // 异或校验字
int i; WriteBuffer[0]=0xaa;
WriteBuffer[1]=0x0;
WriteBuffer[2]=0x0;
WriteBuffer[3]=0x0;
WriteBuffer[4]=0xa5; if (WriteFile(deviceHandle,WriteBuffer,5,&BytesWritten,NULL) && BytesWritten==5)
{
if (ReadFile(deviceHandle,ReadBuffer,17,&BytesRead,NULL) && BytesRead==17)
{
for (i=1;i<=14;i++)
{
checkSum=checkSum ^ ReadBuffer[i];
}
if (checkSum==ReadBuffer[15])
{
if (ReadBuffer[1]==0)
{
for (i=3;i<=14;i++)
{
deviceInfo[i-3]=ReadBuffer[i];
}
deviceInfo[12]='\0';
return 1;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
else
{
return 0;
}
}
else
{
return 0;
}//c#中的调用函数
private void button3_Click(object sender, System.EventArgs e)
{
string aa="12345678901"; if (GetDeviceInfo(this.handle,aa)==0)
{
MessageBox.Show("读设备信息失败");
}
else
{ MessageBox.Show("设备信息:"+aa);
}
}
我调试dll看到deviceInfo确实修改了
for (i=3;i<=14;i++)
{
deviceInfo[i-3]=ReadBuffer[i];
}
deviceInfo[12]='\0';
return 1;
你没贴出来啊,倒是贴出了很多不必要的代码。
C#中应该这样写吧?[DllImport....]
GetDeviceInfo (Handle, out string)调用时是GetDeviceInfo (this.handle, out aa)
你不声明为传出参数当然不行。