C#调用LabView 数据采集VI生成的DLL
各位大神,本人最近使用C#开发一个项目使用NI-DQA PCI-6229采集电压与音频信号.
NI公司有提供了相应的Labview 生成的DLL,静态调用后,运行里面的函数,出现LabView对话加载框,一直加载,程式卡死,将该DLL在 C++Builder上调用一切正常.
大神们帮忙看看哪儿出了问题.
Labview 生成的MeasureAudio.dll,MeasureAudio.h,
MeasureAudio.h 内容如下:
/*
#include "extcode.h"
#pragma pack(push)
#pragma pack(1)
#ifdef __cplusplus
extern "C" {
#endif
void __cdecl Measuresound(int32_t ChannelToProcess,
int32_t samplesPerChannel, char Chanel[], double *THD, double *RMSValue,
double *detectedFrequency, double *detectedAmplitude);
long __cdecl LVDLLStatus(char *errStr, int errStrLen, void *module);
#ifdef __cplusplus
} // extern "C"
#endif
#pragma pack(pop)*/
C#中调用;
[DllImport("MeasureAudio.dll", EntryPoint = "Measuresound", CallingConvention = CallingConvention.Cdecl)]
static extern void Measuresound(int ChannelToProcess, int samplesPerChannel, char[] Chanel, out double THD, out double RMSValue, out double detectedFrequency, out double detectedAmplitude);
//使用button调用该函数Measuresound时出现Labview运行框,程式就一直卡死了.
private void button4_Click(object sender, EventArgs e)
{
double Thd, RMS, Freq, Amp;
try
{
int process = Convert.ToInt32(comboBox1.Text);
char [] Chanel=comboBox2.Text.ToCharArray();
Measuresound(process,1000,Chanel, out Thd, out RMS, out Freq, out Amp);
textBox5.AppendText(Thd.ToString() + "\r\n" + RMS.ToString() + "\r\n" + Freq.ToString() + "\r\n" + Amp.ToString() + "\r\n");
}
catch (Exception ex)
{ MessageBox.Show(ex.Message);}
}