c#.net调用vc++dll文件,高手帮忙看一看哪里有错 30
dll文件原函数是:extern"C"_declspec(dllexport)voidEncrypt(UINTPublicKey,UINTmod,FILE*fipRe,F...
dll文件原函数是:extern "C" _declspec(dllexport) void Encrypt(UINT PublicKey,UINT mod, FILE* fipRe, FILE* fipWr,char* extrName );
c#调用为:
[DllImport("encryption.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Encrypt(uint PublicKey, uint mod, IntPtr fipRe, IntPtr fipWr, string extrName);
private void Encrypt_OK_Click(object sender, EventArgs e)
{
uint PublicKey = Convert.ToUInt32(Pu_K);
uint mod = Convert.ToUInt32(Mo);
IntPtr fipRe = Marshal.StringToHGlobalAnsi(Encrypt_label1.Text);
IntPtr fipWr = Marshal.StringToHGlobalAnsi(Encrypt_label2.Text);
string extrName=null;
Encrypt(PublicKey,mod,fipRe,fipWr,extrName);
}
运行报错:“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”
求高手指教,不胜感激!
dll里有一句typedef unsigned int UINT; 展开
c#调用为:
[DllImport("encryption.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Encrypt(uint PublicKey, uint mod, IntPtr fipRe, IntPtr fipWr, string extrName);
private void Encrypt_OK_Click(object sender, EventArgs e)
{
uint PublicKey = Convert.ToUInt32(Pu_K);
uint mod = Convert.ToUInt32(Mo);
IntPtr fipRe = Marshal.StringToHGlobalAnsi(Encrypt_label1.Text);
IntPtr fipWr = Marshal.StringToHGlobalAnsi(Encrypt_label2.Text);
string extrName=null;
Encrypt(PublicKey,mod,fipRe,fipWr,extrName);
}
运行报错:“尝试读取或写入受保护的内存。这通常指示其他内存已损坏”
求高手指教,不胜感激!
dll里有一句typedef unsigned int UINT; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询