CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: About ActiveX

  1. #1
    Join Date
    Feb 2002
    Location
    China
    Posts
    102

    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.

  2. #2
    Join Date
    Sep 2002
    Posts
    77
    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.

  3. #3
    Join Date
    Feb 2002
    Location
    China
    Posts
    102
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured