我正在使用IBM Access客户端解决方案,必须实现ehllapi.dll的一些功能才能与grean screen交互。
它有this link格式的IBM文档和this link格式的一些有用的示例代码。示例代码实现了一些简单的函数,它工作得很好,但我找不到如何实现这些函数的方法,这些函数必须将包含每个字节特定数据的数据字符串传递给在示例源代码中实现的接口方法。(如Window Status function)
有谁可以帮我?如何创建要传递给下面的C#代码接口的数据字符串?
public class EhllapiFunc
{
[DllImport("PCSHLL32.dll")]
public static extern UInt32 hllapi(out UInt32 Func, StringBuilder Data, out UInt32 Length, out UInt32 RetC);
}谢谢你的帮助。
我尝试使用byte[]创建数据缓冲区参数,如下所示
byte[] buffer = new byte[28];
buffer[0] = (byte)65 // letter A
buffer[4] = (byte)0x01 // the fifth byte (X'01' for set status)
... 然后传递到编辑过的原型中
public class EhllapiFunc
{
[DllImport("PCSHLL32.dll")]
public static extern UInt32 hllapi(out UInt32 Func, out byte[] Data, out UInt32 Length, out UInt32 RetC);
}但是它不起作用!我的代码有什么问题吗?
“我确实喜欢,”battlmonstr说,“它起作用了!”
Protype将是公共类EhllapiFunc
{
[DllImport("PCSHLL32.dll")]
public static extern UInt32 hllapi(out UInt32 Func, Byte[] Data, out UInt32 Length, out UInt32 RetC);
}它的实现将是
Byte[] buffer = new Byte[28]; // Byte[] not byte[]
MemoryStream ms = new MemoryStream(buffer);
BinaryWriter bw = new BinaryWriter(ms);
bw.Write((Byte)65); // letter A
bw.Seek(4, SeekOrigin.Begin); // jump to 5th byte
bw.Write((Byte)0X01) // hexa 01发布于 2019-03-09 22:36:52
似乎可以使用MemoryStream + BinaryWriter构建此数据缓冲区参数,取出byte[]并将其传递给hllapi。为此,您需要将原型更改为采用byte[]而不是StringBuilder,因为在使用窗口状态函数时,它不是ASCII型字符串。根据你想要什么,字节的组成是不同的,正如你上一个链接中所记录的那样。
https://stackoverflow.com/questions/55078191
复制相似问题