Click here to Skip to main content
15,847,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All;

I am working on C++/MFC project where I need to use access control device SDK

acualy I registred SKD DLL (using regsvr32.exe) to create a controller, after

that I Open my MFC project and I added activex controller from the wizard,

the wizad added two classes CZKEM2.h and CZKEM2.cpp then I declared a control

in my h file like "CZKEM20 m_zk"

the error happed when I invoke the method say "Invalid number of parameters"

What I have tried:

where is My code
control h file
C++
<pre>#pragma once

// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++

// NOTE: Do not modify the contents of this file.  If this class is regenerated
// by Microsoft Visual C++, your modifications will be overwritten.

/////////////////////////////////////////////////////////////////////////////

#include "afxwin.h"

class CZKEM2 : public CWnd
{
protected:
	DECLARE_DYNCREATE(CZKEM2)
public:
	CLSID const& GetClsid()
	{
		static CLSID const clsid
			= {0x00853a19,0xbd51,0x419b,{0x92,0x69,0x2d,0xab,0xe5,0x7e,0xb6,0x1f}};
		return clsid;
	}
	virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle,
						const RECT& rect, CWnd* pParentWnd, UINT nID, 
						CCreateContext* pContext = nullptr)
	{ 
		return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID);
	}

	BOOL Create(LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd,
				UINT nID, CFile* pPersist = nullptr, BOOL bStorage = FALSE,
				BSTR bstrLicKey = nullptr)
	{ 
		return CreateControl(GetClsid(), lpszWindowName, dwStyle, rect, pParentWnd, nID,
		pPersist, bStorage, bstrLicKey); 
	}

// Attributes
public:


// Operations
public:
// _IZKEMEvents

// Functions
//

	void OnAttTransaction(long EnrollNumber, long IsInValid, long AttState, long VerifyMethod, long Year, long Month, long Day, long Hour, long Minute, long Second)
	{
		static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4;
		InvokeHelper(0x1, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EnrollNumber, IsInValid, AttState, VerifyMethod, Year, Month, Day, Hour, Minute, Second);
	}
	void OnKeyPress(long Key)
	{
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0x2, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Key);
	}
	void OnEnrollFinger(long EnrollNumber, long FingerIndex, long ActionResult, long TemplateLength)
	{
		static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4 VTS_I4;
		InvokeHelper(0x3, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EnrollNumber, FingerIndex, ActionResult, TemplateLength);
	}
	void OnNewUser(long EnrollNumber)
	{
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0x4, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EnrollNumber);
	}
	void OnEMData(long DataType, long DataLen, signed char * DataBuffer)
	{
		static BYTE parms[] = VTS_I4 VTS_I4 VTS_UNKNOWN;
		InvokeHelper(0x5, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, DataType, DataLen, DataBuffer);
	}
	void OnConnected()
	{
		InvokeHelper(0x6, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr);
	}
	void OnDisConnected()
	{
		InvokeHelper(0x7, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr);
	}
	void OnFinger()
	{
		InvokeHelper(0x8, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr);
	}
STDMETHOD(OnVerify)(long UserID)
	{
		HRESULT result;
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0x9, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, UserID);
		return result;
	}
STDMETHOD(OnFingerFeature)(long Score)
	{
		HRESULT result;
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0xA, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, Score);
		return result;
	}
STDMETHOD(OnHIDNum)(long CardNumber)
	{
		HRESULT result;
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0xB, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, CardNumber);
		return result;
	}
	void OnDoor(long EventType)
	{
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0xC, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EventType);
	}
	void OnAlarm(long AlarmType, long EnrollNumber, long Verified)
	{
		static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4;
		InvokeHelper(0xD, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, AlarmType, EnrollNumber, Verified);
	}
STDMETHOD(OnWriteCard)(long EnrollNumber, long ActionResult, long Length)
	{
		HRESULT result;
		static BYTE parms[] = VTS_I4 VTS_I4 VTS_I4;
		InvokeHelper(0xE, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, EnrollNumber, ActionResult, Length);
		return result;
	}
STDMETHOD(OnEmptyCard)(long ActionResult)
	{
		HRESULT result;
		static BYTE parms[] = VTS_I4;
		InvokeHelper(0xF, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, ActionResult);
		return result;
	}
STDMETHOD(OnDeleteTemplate)(long EnrollNumber, long FingerIndex)
	{
		HRESULT result;
		static BYTE parms[] = VTS_I4 VTS_I4;
		InvokeHelper(0x10, DISPATCH_METHOD, VT_HRESULT, (void*)&result, parms, EnrollNumber, FingerIndex);
		return result;
	}
	void OnAttTransactionEx(LPCTSTR EnrollNumber, long IsInValid, long AttState, long VerifyMethod, long Year, long Month, long Day, long Hour, long Minute, long Second, long WorkCode)
	{
		static BYTE parms[] = VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4;
		InvokeHelper(0x11, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EnrollNumber, IsInValid, AttState, VerifyMethod, Year, Month, Day, Hour, Minute, Second, WorkCode);
	}
	void OnEnrollFingerEx(LPCTSTR EnrollNumber, long FingerIndex, long ActionResult, long TemplateLength)
	{
		static BYTE parms[] = VTS_BSTR VTS_I4 VTS_I4 VTS_I4;
		InvokeHelper(0x12, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EnrollNumber, FingerIndex, ActionResult, TemplateLength);
	}
	void OnGeneralEvent(LPCTSTR DataStr)
	{
		static BYTE parms[] = VTS_BSTR;
		InvokeHelper(0x13, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, DataStr);
	}
	void OnAttTransactionEx_New(LPCTSTR EnrollNumber, long IsInValid, long AttState, long VerifyMethod, long Year, long Month, long Day, long Hour, long Minute, long Second, LPCTSTR WorkCode)
	{
		static BYTE parms[] = VTS_BSTR VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_I4 VTS_BSTR;
		InvokeHelper(0x14, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, EnrollNumber, IsInValid, AttState, VerifyMethod, Year, Month, Day, Hour, Minute, Second, WorkCode);
	}

// Properties
//



};


control cpp file
<pre lang="C++">
// Machine generated IDispatch wrapper class(es) created by Microsoft Visual C++

// NOTE: Do not modify the contents of this file.  If this class is regenerated
// by Microsoft Visual C++, your modifications will be overwritten.
#include "pch.h"
#include "CZKEM2.h"

/////////////////////////////////////////////////////////////////////////////
// CZKEM2

IMPLEMENT_DYNCREATE(CZKEM2, CWnd)

/////////////////////////////////////////////////////////////////////////////
// CZKEM2 Properties

/////////////////////////////////////////////////////////////////////////////
// CZKEM2 Operations


My MFC code
C++
<pre>void CzkTestDlg::OnBnClickedOk()
{
//m_zk is a control created in h file like "CZKEM20 m_zk";
	m_zk.OnDoor(1);

}
Posted
Updated 7-Apr-23 13:28pm
Comments
jeron1 15-Mar-23 10:18am    
Not sure if this will help but generally, initializing an array looks something like,

int anArray[] = {1,2,3,4};

Your parms array initialization seems wrong.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900