Re: ATL console applcation using ActiveX control
This looks like a perfectly normal versioned ProgID to me...
Are you confusing it with version-independent ProgIDs?
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Brian Muth" <bmuth@mvps.org> wrote in message
news:Oj6kfqTxGHA.4944@TK2MSFTNGP02.phx.gbl...
Looking for something like this: (not working)
#include <windows.h>
#include <atlcomcli.h>
#import "myControl.ocx" no_namespace
int main(int argc, char **argv)
{
CComPtr<_DMyControl> com_ptr;
HRESULT hr;
hr = CoInitialize(0);
if (SUCCEEDED(hr))
{
hr = com_ptr.CoCreateInstance(L"MyControl.MyControlCtrl.1");
if (SUCCEEDED(hr))
printf("Get age: %dn", com_ptr->getAge());
else
printf("ActiveX Error.\n");
}
else
printf("COM Error.\n");
}
So what is wrong in this code?
What is the value of hr? It will tell you what's wrong.
By the way, your ProgID doesn't look right for a VB ActiveX control. I'm
guessing that it should be "MyControl.MyControlCtrl1".
Instead of using a ProgID, I prefer to use the _uuidof operator to
retrieve the GUID associated with the ocx class, as in:
hr = com_ptr.CoCreateInstance (__uuidof (DMyControl));
Note there is no leading underscore, since I want to stipulate the class,
not the interface.
HTH,
Brian