/********************************************************************************\
* This sample is supplied as is with no implied warranty.
* It is designed to assist you in using the Cisco AnyConnect VPN API.
* It is assumed that you will build a production application and
* refer to this sample as a reference only.
\********************************************************************************/
#include "stdafx.h"
#include "CppComSample.h"
#include "CppComSampleDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
BEGIN_MESSAGE_MAP(CCppComSampleApp, CWinApp)
ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
END_MESSAGE_MAP()
//You need a global CComModule to use ATL COM coclass like CEventCallBack.
//NOTE: CComModule is used so that this example can be potentially backported to VC6.
// You can convert this to ATL 7.x or later COM if you want to.
CComModule _Module;
CCppComSampleApp::CCppComSampleApp()
{
}
// The one and only CCppComSampleApp object
CCppComSampleApp theApp;
BOOL CCppComSampleApp::InitInstance()
{
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES | ICC_STANDARD_CLASSES;
::InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
//Initialization of COM. In this sample, COM is intentionally initialized
//in STA mode so that the developer does not have to worry about threading and
//serialization. See ReadMe_First.htm for more details on this topic.
//
HRESULT hr = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED
| COINIT_DISABLE_OLE1DDE
| COINIT_SPEED_OVER_MEMORY);
if (FAILED(hr))
{
::MessageBox(::GetDesktopWindow(), _T("Unable to initialize COM"),
_T("ERROR"), MB_OK | MB_ICONERROR);
return FALSE;
}
else
{
AfxEnableControlContainer();
SetRegistryKey(_T("AnyConnect VPN API Sample COM Application"));
CCppComSampleDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
elseif (nResponse == IDCANCEL)
{
}
} // This scopes all COM smart pointers to ensure they are released.
//All smart pointers must be cleaned up before COM is uninitialized or a crash will occur.
::CoUninitialize();
return FALSE;
}
My educated guess: On line 60, a "CCppComSampleDlg" object is created, and it inherits from IVpnApiEvents, which has some pure virtual functions. The CCppComSampleDlg class does not redefine some of the pure virtual methods, so it can't be initialized as some of the functions aren't defined.
Or if "CCppComSampleDlg" does not inherit IVpnApiEvents, it contains either an object of IVpnApiEvents, or an object which inherits IVpnApiEvents but does not override the virtual functions.
So the same error will happen.