If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

COleVariant in WinAPI (afxdisp.h)

however the only one thing that does not seem to work with my OLE is COleVariant class.
It's simply not declared. I tried adding afxdisp.h but it's not a standard lib in my Microsoft Visual Visual Studio Express 2012 and it seems to be very specific to MFC.

I tried to add it manually from internet but it's then referring (calling) to other *.h

is there any way to either replace COleVariant with VARIANT (or something) or add afxdisp.h (and all connected libs) to my program?
i wanna achieve this :

Re: COleVariant in WinAPI (afxdisp.h)

it doesnt really help coz i simply donno how to do this.
i would like to use ATL and MFC libs in my VC Express 2012 version. i tried few links with using SDK but all refer to old version of SDK and VC Express 2008 which is completely different to mine.
There must be some way to put those lib into my program.

Re: COleVariant in WinAPI (afxdisp.h)

Ok.. I tried to run it with ATL and MFC libs, i installed 30days version of VC Prof 2012, and although COleVariant worked, there is a lot of dependencies when i started adding ATL libs. i cannot even compile my program with windows.h anymore coz ATL does not go along with win32 app, i got hundred of warnings and errors, i permanently gave up with this approach.
I guess my last chance now is to find some way to convert COleVariant to something else.

Sorry! I missed this erroneos assignments.
VT_I1 means theat the value is of type char (one and only one char symbol!) while you are trying to pass in the char* (a ponther to char array)
Try to change your code to be:

where this OLEMethod is called by (/from):
m_hr=OLEMethod(DISPATCH_PROPERTYGET, &result, pSheet, L"Range", 1, xx);

I guess i did some stupid mistake when i was copying the code from some example, not fully understanding it.
I believe you are right saying that it must have somethign to do with that conversion thing which i dont quite understand yet.

Well, Did you read the documentation about VARIANT in MSDN?
It states that for pcVal you have to use VT_BYREF | VT_I1. And if you set the type as VT_BSTR you have to set the bstrVal, not a B]pcVal[/B].

And again: why do you use such a mixture of L"...", T("...") and "..."?

Re: COleVariant in WinAPI (afxdisp.h)

szName is defined as size 200, but WideCharToMultiByte is told that is is 256!

Also, you are not testing the return value from WideCharToMultiByte to determine if the function succeeded or failed.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!