Two DLL questions.

I'll split the points if need be.
First, I need to export an enumerator from a dll.  How is this done?  In the source and in an ODL file.
Second, in an odl file, how do you specify default function parameters?  The API has, among others, two default parameters of type int.  In the calling application, if I don't specify them, the call goes to the dll with 0 values for the int parameters.  What I want is for those parameters to be left off completely.  I tried to specify the defaults in the odl file, but it won't take them, or I'm doing it wrong.
The dll is written in C++, but is used from VB apps.  It is VB friendly so far, and I like to keep it that way.

The API looks like this
__declspec(dllexport) int _stdcall FunctionName(const char x[], const char y[], const char z[], const int i = lcDefault, const int j = ccDefault);
In the ODL file it looks like this
int _stdcall FunctionName(LPSTR x, LPSTR y, LPSTR z, int i, int j);
       
kpcapelAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
abancroftConnect With a Mentor Commented:
You can't export it from the DLL in the same way you export a function. But you can add it to the ODL file (& therefore the type library).

Use:
enum [tag ]
{
    identifier [=integer-value ]
    [ , ... ]
}

e.g.
typedef enum {Monday=2, Tuesday, Wednesday, Thursday, Friday} workdays;
0
 
abancroftCommented:
What do you mean by "an enumerator"? Could you be a bit more precise?

Default parameters in ODL: use defaultvalue(value). e.g.
interface QueryDef : IUnknown
{
    HRESULT OpenRecordset( [in, defaultvalue(DBOPENTABLE)]
    LONG Type,
    [out,retval] Recordset **pprst);
}
//  Type is now known to be a LONG type (good for browser in VBA and
//  good for a C/C++ programmer) and has a default value of
//  DBOPENTABLE
 
0
 
kpcapelAuthor Commented:
I was referring to a standard enum.  Microsoft has plenty in various dll's.

typedef enum TAnimals
{
      aDog,
      aCat,
      aFish,
      aMoose
}EAnimals;
0
 
kpcapelAuthor Commented:
Guess I should have checked the platform SDK a little better.
Thanks for your answer.
0
All Courses

From novice to tech pro — start learning today.