-
About ActiveX
I construct an ActiveX Control and try to get data from the control thru a function GetData(VARIANT FAR* feature, short FAR* size_of_feature).
Then I apply the control in an exe application program. But now i encounter a problem, that is I can't get data from the function and system error is "Access voilation".
My program section is:
VARIANT f;
short size_f;
my_ctrl.GetData(&f, &size_f);
Pls help me. Thank you.
-
First you should state explicitly your parameters as out-parameters in the IDL:
Code:
HRESULT GetData([out] VARIANT* feature, [out] short* sof);
Then you should initialize the variant before passing it to GetData:
Code:
VariantInit(&f);
my_ctrl.GetData(...);
If you still get the access violation there must be a bug inside the GetData-function. Show the code how/where you assign values to the parameters.
-
Actually, I wanna get a BYTE type array by the VARIANT variable. In the function GetData(...) I did not allocate for the variable pbVal of the struct VARIANT, so system error happened. Now I correct it.
Thank you very much.