4. 編寫實現函數功能的代碼
ValidateCard.cpp清單
--------------------------------------------------------------------------------
// ValidateCard.cpp : Implementation of CValidateCard
#include "stdafx.h"
#include "ValidateCreditCardServer.h"
#include "ValidateCard.h"
/////////////////////////////////////////////////////////////////////////////
// CValidateCard
STDMETHODIMP CValidateCard::ValidateCreditCard(BSTR bstrCCNo, BSTR bstrCCType, long *val)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
// TODO: Add your implementation code here
CString strType(bstrCCType);
strType.MakeUpper();
if(strType.Compare("VISA")==0)
bstrCCType=SysAllocString(OLESTR("V"));
else if(strType.Compare("MASTER")==0)
bstrCCType=SysAllocString(OLESTR("M"));
else if(strType.Compare("AMERICAN")==0)
bstrCCType=SysAllocString(OLESTR("A"));
else
{
*val=0;
return S_FALSE;
}
if((PrefixCheck(bstrCCNo,bstrCCType)==S_OK) && (LengthCheck(bstrCCNo,bstrCCType)==S_OK) && (LuhnCheck(bstrCCNo,bstrCCType)==S_OK))
{
*val=1;
return S_OK;
}
else
{
*val=0;
 
[1] [2] [3] [4] 下一頁