将C#System.Text.Encoding.Default.GetString(outPath, 0, outLen);函数改写成VB6代码怎么写?

美薇 2017-03-08 07:19:47
初学VB6,现在有C#编写的例程,需要吧这个过程改成VB6的,老是错误,特别是System.Text.Encoding.Default.GetString(outPath, 0, outLen);
在VB6里用什么函数?怎么传递值?请赐教,越详细越好。
下面是部分C#代码:

public partial class Form1 : Form
{
[DllImport("FTDetectUCamera.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "ftGetSnapedImagePath")]
public static extern int ftGetSnapedImagePath(int channel, byte [] outPath, ref int outLen);

string imgFile1;
string imgFile2;
int camIndex = 0; //打开第0个USB摄像头,最多打开6个
void Go()
{
byte[] outPath = new Byte[256];
int outLen = 0;
int ret = ftGetSnapedImagePath(camIndex, outPath, ref outLen);
string imgpath = System.Text.Encoding.Default.GetString(outPath, 0, outLen);
//获取原始抓拍图片
//ret = ftGetFullSnapedImagePath(camIndex, outPath, ref outLen);
//imgpath = System.Text.Encoding.Default.GetString(outPath, 0, outLen);
if (ret == 0 && imgpath != "")
{
Image img = Image.FromFile(imgpath);
if (img != null)
{
pictureBox1.Image = img;
imgFile1 = imgpath;
}
}
}

这一句“ string imgpath = System.Text.Encoding.Default.GetString(outPath, 0, outLen);“”使用VB6怎么写代码
请帮忙
...全文
200 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Tiger_Zhao 2017-03-10
  • 打赏
  • 举报
回复
Private Declare Function ftGetSnapedImagePath Lib "FTDetectUCamera.dll" ( _
ByVal chn As Long, _
ByRef outPath As Byte, _
ByRef outLen As Long _
) As Long

Dim ret As Long
Dim camIndex As Long
Dim outPath(255) As Byte
Dim outLen As Long
Dim imgPath As String
ret = ftGetSnapedImagePath(camIndex, outPath(0), outLen)
Tiger_Zhao 2017-03-09
  • 打赏
  • 举报
回复
        Dim outPath(255)    As Byte
Dim outLen As Long
Dim imgPath As String
...
imgPath = StrConv(LeftB(outPath, outLen), vbUnicode)
赵4老师 2017-03-09
  • 打赏
  • 举报
回复
不要做A语言代码修改为B语言代码的无用功。 也不要做用A语言代码直接调用B语言代码库这样复杂、这样容易出错的傻事。 只需让A、B语言代码的输入输出重定向到文本文件,或修改A、B语言代码让其通过文本文件输入输出。 即可很方便地让A、B两种语言之间协调工作。 比如: A将请求数据写到文件a.txt,写完后改名为aa.txt B发现aa.txt存在时,读取其内容,调用相应功能,将结果写到文件b.txt,写完后删除aa.txt,改名为bb.txt A发现bb.txt存在时,读取其内容,读完后删除bb.txt 以上A可以替换为任何一种开发语言或开发环境,B可以替换为任何一种与A不同的开发语言或开发环境。 除非A或B不支持判断文件是否存在、文件读写和文件更名。 但是谁又能举出不支持判断文件是否存在、文件读写和文件更名的开发语言或开发环境呢? 可以将临时文件放在RamDisk上提高效率减少磨损磁盘。 数据的结构很复杂的话,文本文件的格式问题可参考json或xml 共享临时文本文件这种进程之间的通讯方法相比其它方法的优点有很多,下面仅列出我现在能想到的: ·进程之间松耦合 ·进程可在同一台机器上,也可跨机,跨操作系统,跨硬件平台,甚至跨国。 ·方便调试和监视,只需让第三方或人工查看该临时文本文件即可。 ·方便在线开关服务,只需删除或创建该临时文本文件即可。 ·方便实现分布式和负载均衡。 ·方便队列化提供服务,而且几乎不可能发生队列满的情况(除非硬盘空间满) ·…… “跨语言、跨机,跨操作系统,跨硬件平台,跨国,跨*.*的”苦海无边, 回头是“使用共享纯文本文件进行信息交流”的岸!
美薇 2017-03-09
  • 打赏
  • 举报
回复
public static extern int ftGetSnapedImagePath(int channel, byte [] outPath, ref int outLen); 这样声明对吗 Private Declare Function ftGetSnapedImagePath Lib "FTDetectUCamera.dll" (ByVal chn As Long, ByRef outPath() As Byte, ByRef outLen As Long) Dim ret As Long Dim camIndex As Long Dim outPath(255) As Byte Dim outLen As Long Dim imgPath As String ret = ftGetSnapedImagePath(camIndex, outPath, outLen) 老是错误

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧