Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. ATL 7.0 Passing SafeArrays

ATL 7.0 Passing SafeArrays

Scheduled Pinned Locked Moved COM
c++help
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nicholas Cardi
    wrote on last edited by
    #1

    I want to pass a SafeArray to a VB Client but I can't seem to get the right syntax for the IDL. Can someone please help me. Forever Developing

    J 1 Reply Last reply
    0
    • N Nicholas Cardi

      I want to pass a SafeArray to a VB Client but I can't seem to get the right syntax for the IDL. Can someone please help me. Forever Developing

      J Offline
      J Offline
      J Dunlap
      wrote on last edited by
      #2

      [attributes] LPSAFEARRAY *varname

      N 1 Reply Last reply
      0
      • J J Dunlap

        [attributes] LPSAFEARRAY *varname

        N Offline
        N Offline
        Nicholas Cardi
        wrote on last edited by
        #3

        I should have been more clear. I want to pass the SafeArray pointer out to VB 6 in ATL 3.0. I used to be able to do this with the following code. foo(SAFEARRAY(long) *psa); However the same thing in ATL 7.0 won't compile NOTE: I am using an emedded idl VS.NET //Actual code #define _ATL_ATTRIBUTES 1 #include "stdafx.h" #include "resource.h" #include "atlbase.h" #include "atlcom.h" #include "oleauto.h" #include "atlsafe.h" #include "oaidl.h" // The module attribute causes DllMain, DllRegisterServer and DllUnregisterServer to be automatically implemented for you [ module(dll,name="ATL7TEST")]; [object, dual, uuid(4D9BCA91-2F02-4cee-A589-2CC4D9821156)] __interface IATL7TEST { HRESULT TestRaiseEvent(); }; [object,uuid("8D0F6D5E-DDC3-4371-BB08-49864F5DE356")] __interface _IATL7EVENTS { HRESULT MyFirstEvent(SAFEARRAY(long*) *varname ); }; [coclass, uuid(EBAA6CB2-ED31-4e08-8DF8-068B2978C3F7),event_source(com)] class TESTING : public IATL7TEST { public: __event __interface _IATL7EVENTS; HRESULT TestRaiseEvent() { CComSafeArray Test; SAFEARRAY *psa; SAFEARRAYBOUND rgsabound[1]; rgsabound[0].lLbound = 0; rgsabound[0].cElements = 10; psa = SafeArrayCreate(VT_INT, 1, rgsabound); long test; test = 1234; LPSAFEARRAY lpsa; lpsa = psa; __raise MyFirstEvent(psa); return S_OK; } }; //compilation errors //v:\ATL7TEST\ATL7TEST.cpp(33): error C2061: syntax error : identifier 'tagSAFEARRAY' //v:\ATL7TEST\ATL7TEST.cpp(33): error C2059: syntax error : ')' //v:\ATL7TEST\ATL7TEST.cpp(33): error C2143: syntax error : missing ')' before ';' Forever Developing

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups