C#调用VC6编写的DLL结果不对的问题?

[复制链接]
查看11 | 回复1 | 2007-10-20 08:38:44 | 显示全部楼层 |阅读模式
VC中头文件定义:void DecodeKey(char * Code, char * Key, char * Result,long file);
void CodeKey(char * Code, char * Key, char * Result,long file);
其中Result为输出参数,其它的为输入参数.
在PB中均可以正常调用该2个函数.PB中调用格式
subroutine vDecodeKey(string as_input,string as_key,ref string as_output, long as_file)library "xcode.dll" ALIAS FOR "DecodeKey"
subroutine vCodeKey(string as_input,string as_key,ref string as_output, long as_file)library "xcode.dll" ALIAS FOR "CodeKey"
string ls_rtn
ls_rtn = space(len(a_input))
CodeKey(a_input,a_key,ls_rtn,0)
return ls_rtn
在C#中调用:
[DllImport("xcode.dll", CharSet = CharSet.Auto)]
public static extern void DecodeKey(string as_input,string as_key,string as_output, long as_file);
[DllImport("xcode.dll", CharSet = CharSet.Auto)]
public static extern void CodeKey(string as_input,string as_key,string as_output, long as_file);
public static string vcodekey(string a_input, string a_key)
{//加密
string ls_rtn;
ls_rtn=new string(' ',a_input.Length);
CodeKey(a_input,a_key,ls_rtn,0);
return ls_rtn;
}
问题是C#中返回的结果不正确,只有第一个字符的结果正确.比如'123'要加密,结果只有'1'这个字符加密了,'23'没有加密,返回还是空格.不知道C#中该怎样调用???
详见:http://community.csdn.net/Expert ... 6.xml?temp=.3956568
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
改成[DllImport("xcode.dll", CharSet = CharSet.Ansi)] 试一下
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行