[DllImport("Channel.dll", EntryPoint = "CAPI_Channel", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel",函数是 CAPI_Channel没有错,EntryPoint出错,请教各位??
public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel",函数是 CAPI_Channel没有错,EntryPoint出错,请教各位??
解决方案 »
- C#实现手动开启和关闭无线网卡的动作
- 关于“启用了Silverlight 的 WCF 服务”的一点小疑问
- 求一条正则表达式
- vs2008的安装问题,报unable to find baseline data,请高手赐教,有图有真相。
- 请高人指点迷津:2. 在各界面录入信息时,输入法默认总是全角状态,这样数字输入不正常
- c#中,如何判断richTextBox中的内容在上一次保存之后发生了修改?
- 急急急急急急急急急急急啊,WINFORM程序懂的来,谢谢各位,
- 如何在非windows程序中,监控键盘,鼠标等设备?
- 怎么实现按Enter键从一个TextBox到另一个?
- C#中判断是不是日期
- 求sql 语句,没有遇到过这种情况!
- 改变DATAGRID颜色的问题
CallingConvention = CallingConvention.StdCall如果C里的定义不是stdcall的,就去掉
"?CAPI_Channel@@YA?AUchannel_output@@HPANH@Z",
我把EntryPoint改了下,发现不报错,但是算出来的结果是错误的
不知道为什么?我在C++下调用是没有问题的
public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel",
CharSet = CharSet.Auto 改为CharSet.Unicode 试试看
EntryPoint 只能用那一长串“乱码”CallingConvention 得用 Cdecl
如果内容为空的话,就不行。C#里调用的DLL应该是标准库文件。
定义:
#pragma comment(lib,"Channel.lib")
_declspec (dllimport) channel_output CAPI_Channel(int, double *, int);
结构体typedef struct
{
int zc; // 声速分布分层数(2-254)
double z[256],c[256]; // 深度(0.-xxxxx.)、声速(xxxx.)
double CoeffSurfaceReflection;
double SeaWaterDensity;
double SeaWaterVelocity;
double SeaFloorDensity;
double SeaFloorVelocity; // 接收机位置
double ReceiverRange;
double ReceiverDepth;
double SourceRange;
double SourceDepth;
double VerticalDirectionMin;
double VerticalDirectionMax;
double FrequencyMin;
double FrequencyMax;
double CentreFrequency;
double SamplingFrequency;
double SignalImpluseWidth;
int ChannelOption;
} channel_input;typedef struct
{
double t_tmin;
double t_Amax;
double TL;
} channel_output;C#中:
定义
[DllImport("Channel.dll", EntryPoint = "?CAPI_Channel@@YA?AUchannel_output@@HPANH@Z")]
public static extern channel_output CAPI_Channel(int a, double[] b, int c); //EntryPoint = "CAPI_Channel",
结构体:
public struct channel_input
{
public int zc;
public double[] z ;
public double[] c ;
public double CoeffSurfaceReflection;
public double SeaWaterDensity;
public double SeaWaterVelocity;
public double SeaFloorDensity;
public double SeaFloorVelocity;
public double ReceiverRange;
public double ReceiverDepth;
public double SourceRange;
public double SourceDepth;
public double VerticalDirectionMin;
public double VerticalDirectionMax;
public double FrequencyMin;
public double FrequencyMax;
public double CentreFrequency;
public double SamplingFrequency;
public double SignalImpluseWidth;
public int ChannelOption;
}
[StructLayout(LayoutKind.Sequential)]
public struct channel_output
{
public double t_tmin;
public double t_Amax;
public double TL;
}
就这样,我觉得这个关系不大,主要是参数的输入输出有问题
double[] b这个参数到底是用来传入还是传出数据?如果是传出的,那么它的实参分配了足够大的内存吗?