?
Solved

Automation Type not supported

Posted on 2003-02-23
7
Medium Priority
?
190 Views
Last Modified: 2010-04-01
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
Comment
Question by:inorse
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:BeyondWu
ID: 8005295
Try to use float a; instead of float* a;
0
 
LVL 22

Expert Comment

by:ambience
ID: 8006227
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
 

Author Comment

by:inorse
ID: 8009427
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:BeyondWu
ID: 8012734
John,

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

Wu
0
 

Author Comment

by:inorse
ID: 8018950
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
 
LVL 22

Accepted Solution

by:
ambience earned 900 total points
ID: 8022878
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
 

Author Comment

by:inorse
ID: 8276923
Didn't solve my problem, but I found out what can be done and can't be done.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question