有rd2Image::Program::ConvertWordToImage”: 不能将参数 7 从“System::Single ^”转换为“float”
问题代码:
pProgram->ConvertWordToImage("F:\\111.doc","","",0,0,nullptr,pFloat);
该函数原型为:
public void ConvertWordToImage(string wordInputPath, string imageOutputPath, string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution
问题代码:
pProgram->ConvertWordToImage("F:\\111.doc","","",0,0,nullptr,pFloat);
该函数原型为:
public void ConvertWordToImage(string wordInputPath, string imageOutputPath, string imageName, int startPageNum, int endPageNum, ImageFormat imageFormat, float resolution
你传 *pFloat 试试
float 在c++ 中不是指针类型,我也不懂托管c++瞎写的, 有个程序是C#开发的, 想包装它一下,我不会修改C#代码,所以才用托管包装之。已经解决了。就是*pfloat.
为什么要这么修改 ?
*pfloat是实际的数据,是single类型的(也是float类型)
多谢指教
为了捕捉C#里的函数ConvertWordToImage的异常,所以我再托管c++中写了这样的代码,结果编译不了
char strResultMsg[100]={0};
Exception^ pException=gcnew Exception();
try
{ pProgram->ConvertWordToImage(pWordFileName,"","",0,0,nullptr,*pResolution);
strcpy(strResultMsg,"成功");
}
catch(pException)
{
sprintf(strResultMsg,"异常信息:%s",pException->Message.ToCharArray());
}C#的部分代码为:try
{
...........................
}
catch (Exception ex)
{
throw ex;
}
改成:try
{}
catch(Exception^ pExp)
{
//获取异常信息pExp->ToString();
}