Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Nidaq DLL could not be called due to interface error

I am attempting to access information from a module on a PXI-1000B chassis for the first time using the GetDAQDeviceInfo command (CWDaqTool). However I keep getting the response "Ni-daq DLL could not be called due to interface error". Any help would be greatly appreciated.

Rodney 😃

Here is my code:

// Trial1Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "Trial1.h"
#include "Trial1Dlg.h"


/////////////////////////////////////////////////////////////
#include "nidaq.h" // National Instruments Header File /
#include "nidaqcns.h" // National Instruments Header File /
#include "nidaqerr.h" // National Instruments Header File /
#include "nidaqex.h" // National Instruments Header File /
/////////////////////////////////////////////////////////////


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
CAboutDlg();

// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA

// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL

// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTrial1Dlg dialog

CTrial1Dlg::CTrial1Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CTrial1Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTrial1Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CTrial1Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTrial1Dlg)
DDX_Control(pDX, IDC_CWDAQTOOLS1, m_CWDaqTools);
//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CTrial1Dlg, CDialog)
//{{AFX_MSG_MAP(CTrial1Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_GETINFO, OnGetinfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTrial1Dlg message handlers

BOOL CTrial1Dlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here

return TRUE; // return TRUE unless you set the focus to a control
}

void CTrial1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}

// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.

void CTrial1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting

SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;

// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}

// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CTrial1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}

#include "cwdaqtools.h"

void CTrial1Dlg::OnGetinfo()
{
COleVariant Info;

long Status;

long DeviceNumber = 1;
long InfoType = ND_DEVICE_NAME;


// Get information on the chassis
Status = m_CWDaqTools.GetDAQDeviceInfo(DeviceNumber, InfoType, Info);

}
0 Kudos
Message 1 of 6
(5,361 Views)
Hi Rodney,

I believe what is happening is that you are using the NI-DAQ InfoTypes rather than the ComponentWorks InfoTypes. The one you want is probably cwGetDeviceName.

I will include at the bottom of this posting a list of the ComponentWorks InfoTypes.

I got the list of types (on my computer at least) from:
start->programs->National Instruments->MeasurementStudio->Help->Measurement Studio Reference

That help file is part of Measurement Studio 6, so if you are using Measurement Studio 1 you will need to use the reference included with that.

I hope this is what you are looking for.

Sincerely,

John N
Applications Engineer
National Instruments

You can use the following constants with this data type:
cwGetAITransferMode–Data transfer mod
e for analog input
cwGetAOGroup1TransferMode–Data transfer mode for analog output Group 1
cwGetAOGroup2TransferMode–Data transfer mode for analog output Group 2
cwGetBaseAddress–Base address
cwGetComputerName–Computer name
cwGetCounterType–Counter type.
cwGetDAQCard700CounterSource–DAQCard-700 counter source
cwGetDeviceName–Device name
cwGetDeviceTypeCode–Device type code
cwGetDIOGroup1TransferMode–Data transfer mode for digital I/O Group 1
cwGetDIOGroup2TransferMode–Data transfer mode for digital I/O Group 2
cwGetDMAALevel–DMA A level
cwGetDMABLevel–DMA B level
cwGetDMACLevel–DMA C level
cwGetGPCTR0TransferMode–Data transfer mode for GPCTR 0
cwGetGPCTR1TransferMode–Data transfer mode for GPCTR 1
cwGetInterruptALevel–Interrupts A level.
cwGetInterruptBLevel–Interrupts B level.
cwGetInterruptGenerationMode–Interrupts generation mode.
cwGetLPTD
eviceMode–LPT device mode
cwGetNIDAQVersion–NI-DAQ version
cwGetSerialNumber–Serial number.
cwGetSuspendDeviceState–Device state during suspend mode
0 Kudos
Message 2 of 6
(5,361 Views)
Thanks for the heads up John, but there is one catch here. The NI-DAQ InfoTypes, such as 'cwGetDeviceName' are stored in the 'nidaqcns.h' header file, but where are the ComponentWorks InfoTypes stored??? I can't use them without including the proper header file.

Do you know of any examples which retrieve information using the ComponentWorks InfoTypes???
0 Kudos
Message 3 of 6
(5,361 Views)
Never mind John, I understand what you meant. I found the correct component works infotypes. Thank you for you help. It is appreciated.

Rodney 😃
0 Kudos
Message 4 of 6
(5,361 Views)
You didn't say what OS you were using, but this sounds like a known issues with NI-DAQ and Visual Studio under Windows 2000. There is a DLL base address problem that hinders loading some DLL's with 6.8.1 and 6.9.0 of NI-DAQ under Windows 2000. There is a knowledgebase article with a patch that should fix it here: http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/6b75ca1982574cb7862569ae00784fff?OpenDocument.

If this does NOT fix it, contact our tech support staff at http://www.ni.com/ask and we'll help you with it.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 5 of 6
(5,360 Views)

Nidaq DLL could not be called due to interface error

 

There was a post by Chris Matthews National Instruments, indicating a knowledge base article with a patch: 

http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/6b75ca1982574cb7862569ae00784fff?OpenDocument

However, this link now returns a messge: "You are not authorized to view this document"

I am doing a minor update for a past project, but I can not complete compiling due to this interface error.  

 

OS is Windows 2000, VB6, Measurement studio

 

Thanks in advance!

0 Kudos
Message 6 of 6
(3,708 Views)