• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 192
  • Last Modified:

Automation Type not supported

My program has the following VB6 type (one out of many) definition;

Type ABC
     a as Long
     b as Integer
End Type

The program passes the above type to a C++ DLL, which has a

corresponding struct;

typedef struct
{
     float *a;
     short  b;
} ABC;

It works like charm. However, I would like to make the C++ DLL more accessible to VB with a Type Library instead. I followed Microsoft Knowledge Base Article - Q189133, and compiled without any error. When I then run the program, VB gives me the error "Variable uses an automation type not supported by VB". I know the reason is that VB won't accept that 'a' is a pointer to a float in the C++ struct.

Is there any work around?

John



 
0
inorse
Asked:
inorse
  • 3
  • 2
  • 2
1 Solution
 
BeyondWuCommented:
Try to use float a; instead of float* a;
0
 
ambienceCommented:
is the variable of type struct ?? if it is then a custom structure is not a standard automation type.

The reason, because with automation parameters are passed as array of variants and VB must know how to package a parameter into a variant, which obviously is not possible if you design your own types.

The workaround is either to split the structure and pass individual fields as parameters, or make a safearray fill the array with structure field-values and pass that array instead.

It is cumbersome but that is the price you pay with automation.
0
 
inorseAuthor Commented:
BeyondWu,

The DLL code, as it is, requires a pointer to a float (float *a;) in the struct.

As I mentioned, passing the VB type to to the DLL works because, as far as I know, a referense (address) to 'a' is passed. However, when trying to implement a type library, everything fails.

John
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
BeyondWuCommented:
John,

Would you like to post me a simple VB-app and VC-dll code, I would like to trace it.

Wu
0
 
inorseAuthor Commented:
BeyondWu,

I think ambience is on to something. If you implement a type library, both the passing and the receiving structure has to be identical (no pointers in the parameters).    
0
 
ambienceCommented:
inorse the following link should provide a detailed explaination of what i was upto

http://www.microsoft.com/msj/defaulttop.asp?page=/msj/0696/activex0696.htm
0
 
inorseAuthor Commented:
Didn't solve my problem, but I found out what can be done and can't be done.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now