parithon

parithon

  • NA
  • 1
  • 0

Soundgraph VFD API

Feb 27 2007 4:07 PM

I'm pretty new to programming, and learning on my own, so please take it easy on me if I ask something stupid.

I have a Soundgraph VFD for my MCE and I'm trying to create my own application to pull information from MCE and display it on my VFD.  Soundgraph has created an API to accomplish this but it's created in C++ and the dll can't be used as a COM reference.

I've tried figuring out how to import the DLL using the following C# code:

[DllImport("SG_VFD.dll")]
static extern bool iMONVFD_Init(int Type, int reference);
...
bool bInit = iMONVFD_Init(4,0);

but I always get the following exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format.

Can somebody please help me understand how to read the header file to create an appropriate C# method using DllImport?

SG_VFD.h:
#ifndef __SG_VFD_H__
#define __SG_VFD_H__

#ifdef IMONVFD_EXPORT
 #define IMONVFD_API __declspec(dllexport)
#else
 #define IMONVFD_API __declspec(dllimport)
#endif


#define VFDHW_IMON_VFD  4

#ifdef __cplusplus
extern "C" {
#endif

///////////////////////////////////////////////
// Open VFD driver and initialize parameters.
// Call this method, when application starts.
// Return value informs driver is open or not
IMONVFD_API bool iMONVFD_Init(int vfdType, int resevered=0);

///////////////////////////////////////////////
// Close VFD driver.
// Call this method, when application destroyed.
IMONVFD_API void iMONVFD_Uninit(void);

///////////////////////////////////////////////
// Check if VFD driver is opened.
IMONVFD_API bool iMONVFD_IsInited(void);

///////////////////////////////////////////////
// Send text data to VFD. VFD supports only English character set.
IMONVFD_API bool iMONVFD_SetText(char* szFirstLine, char* szSecondLine);

///////////////////////////////////////////////
// Send EQ data to VFD.
// Total 16band, each band ranges from 0 to 100
//  make EQ data with integer array.
IMONVFD_API bool iMONVFD_SetEQ(int* arEQValue);

#ifdef __cplusplus
} // extern "C"
#endif

#endif //__SG_VFD_H__