/* $Revision: 1.1 $ */

#ifndef _MCLXLMAIN_H_
#define _MCLXLMAIN_H_

#include "mclcom.h"

#ifdef __cplusplus
    extern "C" {
#endif
/* Register a MatLab Excel Builder component */
HRESULT RegisterMatLabComponent(const char* szModuleName,     /* DLL module handle */
                                       REFCLSID clsid,               /* Class ID */
                                       REFGUID libid,                /* GUID of TypeLib */
                                       unsigned short wMajorRev,     /* Major rev of type lib */
                                       unsigned short wMinorRev,     /* Minor rev of type lib */
                                       const char* szFriendlyName,   /* Friendly Name */
                                       const char* szVerIndProgID,   /* Programmatic */
                                       const char* szProgID);        /* IDs */
/* Unregister a MatLab Excel Builder component */
HRESULT UnRegisterMatLabComponent(REFCLSID clsid,             /* Class ID */
                                         const char* szVerIndProgID, /* Programmatic */
                                         const char* szProgID);      /* IDs */
/* 
   Aquire global lock. Returns 0 for successful aquisition, -1 otherwise.
   If the global mutex is not initialized, or if the wait function fails,
   -1 is returned.
*/
int RequestGlobalLock(void);
/* 
   Release global lock. Returns 0. If the global mutex is not initialized,
   -1 is returned.
*/
int ReleaseGlobalLock(void);
HRESULT GetConversionFlags(IMWFlags* pFlags, MCLCONVERSION_FLAGS flags);
/* Converts an mxArray to a Variant */
int mxArray2Variant(const mxArray* px, VARIANT* pvar, const MCLCONVERSION_FLAGS flags);
/* Converts a Variant to an mxArray */
int Variant2mxArray(const VARIANT* pvar, mxArray** ppx, const MCLCONVERSION_FLAGS flags);
/* 
   If input VARIANT is VT_EMPTY or VT_ERROR && v->scode == DISP_E_PARAMNOTFOUND, returns true.
   Returns false otherwise. If input variant is *|VT_BYREF and reference is NULL, returns true.
   If input variant pointer is NULL, returns true.
*/
bool IsVisualBasicDefault(const VARIANT *v);

void InitConversionFlags(MCLCONVERSION_FLAGS flags);

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

#endif /*_MCLXLMAIN_H_ */