Esempio n. 1
0
void CSinaSvr::Follow(LPCTSTR  lpUID)
{
	TCHAR szUid[20] = _T("2436235444");
	//_tcscpy(szUid,lpUid);
	TCHAR szPost[1024]= {0};
	_stprintf(szPost,_T("uid=%s&f=1&extra=refer_sort%3Apl_content_hisPersonalInfo&_t=0"),szUid);
	int iSize = _tcslen(szPost);
	
	CByteArray arr;
	for (int i = 0; i < iSize; i++)
	{
		arr.Add(szPost[i]);
	}

	TCHAR szHeader[1024] = {0};
	_stprintf(szHeader,_T("Accept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nReferer: http://weibo.com/%s\r\nx-requested-with: XMLHttpRequest"),szUid);

	TCHAR szURL[1024]=_T("http://weibo.com/aj/f/followed");
	COleVariant vPostData = arr;
	COleVariant vURL(szURL, VT_BSTR);
	COleVariant vHeaders(szHeader, VT_BSTR);
	COleVariant vTargetFrameName((LPCTSTR)NULL, VT_BSTR);
	COleVariant vFlags((long) NULL, VT_I4);
	Navigate2(vURL, vFlags, vTargetFrameName,vPostData, vHeaders);

}
Esempio n. 2
0
void CSinaSvr::Login(LPCTSTR lpUserName,LPCTSTR lpPwd)
{

	SetAction(ACT_LOGIN_SINA);
	TCHAR szPost[1024]= {0};
	_stprintf(szPost,_T("username=%s&password=%s&entry=miniblog&act=1&from=referer%3Awww_index"),lpUserName,lpPwd);

	int iSize = _tcslen(szPost);

	CByteArray arr;
	for (int i = 0; i < iSize; i++)
	{
		arr.Add(szPost[i]);
	}

	TCHAR szHeader[1024] = _T("Content-Type: application/x-www-form-urlencoded; charset=UTF-8");

	TCHAR szURL[1024]=_T("http://login.sina.com.cn/sso/login.php");
	COleVariant vPostData = arr;
	COleVariant vURL(szURL, VT_BSTR);
	COleVariant vHeaders(szHeader, VT_BSTR);
	COleVariant vTargetFrameName((LPCTSTR)NULL, VT_BSTR);
	COleVariant vFlags((long) NULL, VT_I4);
	Navigate2(vURL, vFlags, vTargetFrameName,vPostData, vHeaders);

}
Esempio n. 3
0
void CSinaSvr::Forward(LPCTSTR  lpMid,LPCTSTR lpUid,LPCTSTR lpReason)
{
	
	TCHAR szMid[MAX_PATH] = _T("3366217727338022");
	_tcscpy(szMid,lpMid);
	TCHAR szUid[] = _T("2400232192");
	WCHAR szwPost[1024]={0};
	TCHAR szReason[] = _T("ת·¢Î¢²©£¡");
	_tcscpy(szReason,lpReason);
	_stprintf(szwPost,_T("appkey=&mid=%s&style_type=1&reason=%s&_t=0"),szMid,szReason);

	char szPost[1024]= {0};
	WideCharToMultiByte(CP_UTF8, 0, szwPost, -1, szPost, MAX_PATH, NULL, NULL);
	
	int iSize = strlen(szPost);
	
	CByteArray arr;
	for (int i = 0; i < iSize; i++)
	{
		arr.Add(szPost[i]);
	}

	TCHAR szHeader[1024] = {0};
	_stprintf(szHeader,_T("Accept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nReferer: http://weibo.com/%s\r\nx-requested-with: XMLHttpRequest"),szUid);

	TCHAR szURL[1024]=_T("http://weibo.com/aj/mblog/forward");
	COleVariant vPostData = arr;
	COleVariant vURL(szURL, VT_BSTR);
	COleVariant vHeaders(szHeader, VT_BSTR);
	COleVariant vTargetFrameName((LPCTSTR)NULL, VT_BSTR);
	COleVariant vFlags((long) NULL, VT_I4);
	Navigate2(vURL, vFlags, vTargetFrameName,vPostData, vHeaders);

}
Esempio n. 4
0
void CSinaSvr::PostWeibo1(LPCTSTR lpContent)
{

// 	//check URL;
// 	if (m_strCurURL.Find(_T("http://weibo.com/",0)) < 0)
// 		return;
	WCHAR szwPost[1024]={0};
	_stprintf(szwPost,_T("_t=0&pic_id=&text=%s"),lpContent);

	char szPost[1024]= {0};
	WideCharToMultiByte(CP_UTF8, 0, szwPost, -1, szPost, MAX_PATH, NULL, NULL);
	
	int iSize = strlen(szPost);
	
	CByteArray arr;
	for (int i = 0; i < iSize; i++)
	{
		arr.Add(szPost[i]);
	}

	TCHAR szHeader[1024] = {0};
	_stprintf(szHeader,_T("Accept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nReferer: http://weibo.com/%s\r\nx-requested-with: XMLHttpRequest"),m_szCurUID);

	TCHAR szURL[1024]=_T("http://weibo.com/aj/mblog/add");
	COleVariant vPostData = arr;
	COleVariant vURL(szURL, VT_BSTR);
	COleVariant vHeaders(szHeader, VT_BSTR);
	COleVariant vTargetFrameName((LPCTSTR)NULL, VT_BSTR);
	COleVariant vFlags((long) NULL, VT_I4);
	Navigate2(vURL, vFlags, vTargetFrameName,vPostData, vHeaders);
}
Esempio n. 5
0
CTobCompiler::EToken CTobCompiler::GetBinary(CByteArray& bin)
{
    DWORD cache = 1;
    BOOL comment = FALSE;
    for(;;)
    {
        int c = fgetc(m_fsrc);
        if (c == EOF)
        {
            if (!feof(m_fsrc))
                m_err.Format("can not read src file at %p", ftell(m_fsrc));
            else
                m_err = "not found ']' at the end of src file";
            return ERR_SEVERE;
        }
        if (comment)
        {
            if (c == '\n') { ++m_line; comment = FALSE; }
            continue;
        }
        BYTE half = ms_hextable[c];
        if (half < 16)
        {
            cache = (cache << 4) + half;
            if (cache >= 0x100)
            {
                bin.Add((BYTE)cache);
                cache = 1;
            }
        }
        else if (c <= ' ') continue;
        else if (c == '\n') ++m_line;
        else if (c == ']')
        {
            if (cache != 1) bin.Add((BYTE)(cache & 0x0f));
            return SYM_BIN;
        }
        else if (c == ';') { comment = TRUE; continue; }
        else
        {
            m_err.Format("bad hex char 0x%02X", c);
            return ERR_NORMAL;
        }
    }
}
Esempio n. 6
0
BOOL CRegistry::GetBinaryValue(LPCTSTR name_of_value, CByteArray& return_array)
{

    ASSERT(name_of_value != NULL);

    if (name_of_value == NULL) {
        m_ErrorCode = ERROR_INVALID_PARAMETER;
        return(FALSE);
    }

    // Thanks go to Chris Hines ([email protected]) for finding
    // a bug here. If you add entries to the key, then the
    // information retrieved via QueryInfo() may be invalid. This
    // will screw you here. So, we must make sure our information
    // is correct before we attempt to *use* the data.

    QueryInfo();

    DWORD size_of_buffer = m_LongestValueDataLength;

    LPBYTE memory_buffer = (LPBYTE) new BYTE[ size_of_buffer ];

    if (memory_buffer == NULL) {
        m_ErrorCode = ::GetLastError();
        return(FALSE);
    }

    BOOL ret = TRUE;

    KeyValueTypes type = typeBinary;

    if (QueryValue(name_of_value, type, memory_buffer, size_of_buffer) != FALSE) {
        /*
        ** We've got data so give it back to the caller
        */

        return_array.RemoveAll();

        DWORD index = 0;

        while(index < size_of_buffer) {
            return_array.Add(memory_buffer[ index ]);
            index++;
        }

        ret = TRUE;
    }
    else {
        ret = FALSE;
    }

    delete [] memory_buffer;

    return(ret);
}
Esempio n. 7
0
//GPS接收数据事件
void CALLBACK CGPS::GpsOnSeriesRead(void * powner,BYTE* buf,DWORD  dwBufLen)
{
	CGPS * pGps = (CGPS*)powner;
	//得到本类指针
	CByteArray * pArray = &(pGps->m_aRecvBuf);

	//得到缓冲区大小
	int iMaxSize = pArray->GetSize();
	//得到缓冲区所使用的大小
	int iUpperBound = pArray->GetUpperBound();
	for (int i=0;i<dwBufLen;i++)
	{
		pArray->Add(*(buf+i));
	}

	//将收到的数据发给主程序显示出来
	char* pRecvBuf = new char[dwBufLen+1];
	ZeroMemory(pRecvBuf,dwBufLen+1);
	CopyMemory(pRecvBuf,buf,dwBufLen);

	//发送接收串口原始数据WINDOWS消息通知
	//消息处理完毕后,应释放内存
	::PostMessage(pGps->m_pWnd->m_hWnd,WM_GPS_RECV_BUF,WPARAM(pRecvBuf),dwBufLen+1);

	CString strGps;
	//检查是否已经存在有效的GPS数据
	if (pGps->HaveValidGPSData(pArray,strGps))
	{
		PGPSData pGpsData = NULL;
		pGpsData = pGps->AnalyseGpsData(strGps);
		if (pGpsData != NULL) 
		{
			//将接收到的GPS数据填充到最新当前数据
			pGps->m_gpsCurData = (*pGpsData);
			//发送接收有效GPS位置信息WINDOWS消息通知
			//由消息处理函数释放内存
			::PostMessage(pGps->m_pWnd->m_hWnd,WM_GPS_RECV_VALID_LONGLAT,WPARAM(pGpsData),0);
		}
	}
}
Esempio n. 8
0
CByteArray* CMainDlg::InitBlob()
{
	CByteArray* blob	= new CByteArray();		//Creazione del blob contenitore
	dati* pDati				= new dati();					//Creazione della struttura specializzata
	pDati->nVersione	= 0;									//Inserimento del numero di versione
	pDati->alt				= m_pSerieSet->m_Dimensione1;
	pDati->larg				= m_pSerieSet->m_Dimensione2;
	pDati->lung				= m_pSerieSet->m_Dimensione3;
	pDati->massa			= 0;
	pDati->caricoSp		= 0;
	pDati->tipoRott		= 1;

	
	// Riempimento del blob contenitore
	char *p_ary = (char*)pDati;
	for(int i=0;i<sizeof(struct dati);i++)	
		{
		blob->Add(*p_ary);
		p_ary++;
		}
	return blob;	// Restituzione del puntatore al nuovo blob											
}
Esempio n. 9
0
void CSinaSvr::Comment(LPCTSTR lpMid,LPCTSTR lpUID,LPCTSTR lpContent)
{
	TCHAR szMid[MAX_PATH] = _T("3366217727338022");
	TCHAR szUid[] = _T("2400232192");
	WCHAR szwPost[1024]={0};
	TCHAR szContent[1024] = _T("comment-test");
	
	_tcscpy(szMid,lpMid);
	_tcscpy(szUid,lpUID);
	_tcscpy(szContent,lpContent);
	
	_stprintf(szwPost,_T("act=post&mid=%s&uid=%s&forward=0&isroot=1&content=%s&_t=0"),szMid,m_szCurUID,szContent);
	//_stprintf(szwPost,_T("act=post&mid=3366217727338022&uid=1828546224&forward=0&isroot=0&content=comment-test&type=big&_t=0"));
	char szPost[1024]= {0};
	WideCharToMultiByte(CP_UTF8, 0, szwPost, -1, szPost, MAX_PATH, NULL, NULL);
	
	int iSize = strlen(szPost);
	
	CByteArray arr;
	for (int i = 0; i < iSize; i++)
	{
		arr.Add(szPost[i]);
	}

	TCHAR szHeader[1024] = {0};
	_stprintf(szHeader,_T("Accept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nReferer: http://weibo.com/%s\r\nx-requested-with: XMLHttpRequest"),szUid);
	//_stprintf(szHeader,_T("Accept: */*\r\nContent-Type: application/x-www-form-urlencoded\r\nx-requested-with: XMLHttpRequest"),szUid);

	TCHAR szURL[1024]=_T("http://weibo.com/aj/comment/add");
	COleVariant vPostData = arr;
	COleVariant vURL(szURL, VT_BSTR);
	COleVariant vHeaders(szHeader, VT_BSTR);
	COleVariant vTargetFrameName((LPCTSTR)NULL, VT_BSTR);
	COleVariant vFlags((long) NULL, VT_I4);
	Navigate2(vURL, vFlags, vTargetFrameName,vPostData, vHeaders);

}
Esempio n. 10
0
void CSourceODBC::TestFile(void)
{
    {
        SetPosition(0);
        SDBField *colmn = m_database.GetColomn( _T("FILE") );
        CByteArray *p = &colmn->binValue;
        int rew = 432;
    }

    SetPosition(0);
    Edit();
    SDBField *colmn = m_database.GetColomn( _T("FILE") );

    CByteArray *ba = &m_database.GetColomn( _T("FILE") )->binValue;
    ba->RemoveAt(0, ba->GetSize());
    ba->Add(111);

    Set(_T("Comment"), _T("wqe"));
    while(!CanUpdate()) {
        Sleep(10);
    }

    Update();
}
Esempio n. 11
0
void 座位详情页::OnBnClickedButton1()
{	
	UpdateData(TRUE);
	if (flag == 1)
	{
		//flag++;
		if (x = 1)
			strcpy(fileDizhi, "res\\mv1.ini");
		if (x==2)
			strcpy(fileDizhi, "res\\mv2.ini");
		if (x==3)
			strcpy(fileDizhi, "res\\mv3.ini");
	}
	load();
	if (flag == 1)
	{
		//flag++;
		if (x = 1)
			strcpy(fileDizhi, "res\\mv1.ini");
		if (x == 2)
			strcpy(fileDizhi, "res\\mv2.ini");
		if (x == 3)
			strcpy(fileDizhi, "res\\mv3.ini");
	}
	int k,yu=0;
	for (k = 0; k < 16; k++)
	{
		if (str[diDian][changCi][k] == 'k')
		{
			yu++;
			CStatic *pic=NULL;
			switch (k)
			{
			case 0: pic = (CStatic *)GetDlgItem(IDC_STATIC1); break;
			case 1: pic = (CStatic *)GetDlgItem(IDC_STATIC2); break;
			case 2: pic = (CStatic *)GetDlgItem(IDC_STATIC3); break;
			case 3: pic = (CStatic *)GetDlgItem(IDC_STATIC4); break;
			case 4: pic = (CStatic *)GetDlgItem(IDC_STATIC5); break;
			case 5: pic = (CStatic *)GetDlgItem(IDC_STATIC6); break;
			case 6: pic = (CStatic *)GetDlgItem(IDC_STATIC7); break;
			case 7: pic = (CStatic *)GetDlgItem(IDC_STATIC8); break;
			case 8: pic = (CStatic *)GetDlgItem(IDC_STATIC9); break;
			case 9: pic = (CStatic *)GetDlgItem(IDC_STATIC10); break;
			case 10: pic = (CStatic *)GetDlgItem(IDC_STATIC11); break;
			case 11: pic = (CStatic *)GetDlgItem(IDC_STATIC12); break;
			case 12: pic = (CStatic *)GetDlgItem(IDC_STATIC13); break;
			case 13: pic = (CStatic *)GetDlgItem(IDC_STATIC14); break;
			case 14: pic = (CStatic *)GetDlgItem(IDC_STATIC15); break;
			case 15: pic = (CStatic *)GetDlgItem(IDC_STATIC16); break;
			default:MessageBox(_T("k值错误"));
			}
			pic->ShowWindow(SW_SHOW);

		}
		else
		{
			CStatic *pic=NULL;
			switch (k)
			{
			case 0: pic = (CStatic *)GetDlgItem(IDC_STATIC1); break;
			case 1: pic = (CStatic *)GetDlgItem(IDC_STATIC2); break;
			case 2: pic = (CStatic *)GetDlgItem(IDC_STATIC3); break;
			case 3: pic = (CStatic *)GetDlgItem(IDC_STATIC4); break;
			case 4: pic = (CStatic *)GetDlgItem(IDC_STATIC5); break;
			case 5: pic = (CStatic *)GetDlgItem(IDC_STATIC6); break;
			case 6: pic = (CStatic *)GetDlgItem(IDC_STATIC7); break;
			case 7: pic = (CStatic *)GetDlgItem(IDC_STATIC8); break;
			case 8: pic = (CStatic *)GetDlgItem(IDC_STATIC9); break;
			case 9: pic = (CStatic *)GetDlgItem(IDC_STATIC10); break;
			case 10: pic = (CStatic *)GetDlgItem(IDC_STATIC11); break;
			case 11: pic = (CStatic *)GetDlgItem(IDC_STATIC12); break;
			case 12: pic = (CStatic *)GetDlgItem(IDC_STATIC13); break;
			case 13: pic = (CStatic *)GetDlgItem(IDC_STATIC14); break;
			case 14: pic = (CStatic *)GetDlgItem(IDC_STATIC15); break;
			case 15: pic = (CStatic *)GetDlgItem(IDC_STATIC16); break;
			default:MessageBox(_T("k值错误"));
			}
			pic->ShowWindow(SW_HIDE);
		}	
	}
	CByteArray array;    //动态数组
	array.RemoveAll();   //清除动态数组
	array.Add(yu);	 //按字节添加数据
	comKou.put_Output(COleVariant(array));  //发送数据
	save();
	load();
	UpdateData(FALSE);
}
Esempio n. 12
0
// Write Operation
void CFanmotorDlg::wreg(int reg_addr, int datr)
{
	success=1;

	VARIANT r;
	CByteArray baData;
	CStringArray dataStr;

	//separate input 2 bytes datr into 1byte + 1byte
	int datrH=datr/256;
	int datrL=datr%256;

	CString regstring;
	regstring.Format(_T("%02x "),reg_addr);
	CString strinputH;
    strinputH.Format(_T("%02x "),datrH);
	CString strinputL;
    strinputL.Format(_T("%02x"),datrL);

	CString str = regstring+strinputH+strinputL;

	
	int timeout_counter=0;

	if(this->virtual_board)
	{
		WriteVirtualBoardReg(reg_addr, datr, fOTP);
		return;
	}


	int parseResult = ParseString(dataStr,str);
	if (parseResult != -1){
		AfxMessageBox(L"Incorrect Data (\""+dataStr[parseResult]+L"\") is Typed. Please correct it",
						MB_ICONERROR | MB_OK,0);
		return;
	}
	else{
		if (dataStr.GetSize() == 0) {
			AfxMessageBox(L"Type some HEX data to send!",MB_ICONERROR | MB_OK,0);
			return;
		}
	}
	for (int i=0; i<dataStr.GetSize(); i++) {
		WCHAR *ch,*buf;
		buf = dataStr[i].GetBuffer(dataStr[i].GetLength());
		BYTE dataByte = (BYTE)wcstol(buf,&ch,16);
		dataStr[i].ReleaseBuffer();
		baData.Add(dataByte);
	}

	COleVariant data(baData); // Create array of Data
	// Send Data To Bridge

	r = Bridge->SendIICdata(L"0000011", 0x49, data);//spi comm, no acknowledge signal return to r.cannot check connection success.

	//do{
	//	timeout_counter++;
	//	if (timeout_counter == TIMEOUT){
	//		DisplayInforMessageBox((LPCWSTR)L"Error", (LPCWSTR)L"Device is not available.\nPlease check your hardware connection and power supply!");
	//		success = 0;
	//	}
	//	r = Bridge->SendIICdata(L"0000011", 0x49, data); 
	//}while ((r.bVal != 34) && (timeout_counter != TIMEOUT));

    Sleep(20);
end:;
}
Esempio n. 13
0
BOOL CTyAnimate_Prop::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
    m_listbmp.SetRectType(false);
    m_listbmp.SetColumnType(false);
    m_listvec.SetRectType(false);
    m_listvec.SetColumnType(false);

    CStringArray Head;
    CByteArray   Cols;
    Head.Add("序号");
	Cols.Add(20);
	Head.Add("图名");
	Cols.Add(60);
	Head.Add("透明色");
	Cols.Add(20);
	m_listbmp.InitCtrl(&Head, &Cols);

    Head.RemoveAll();
	Cols.RemoveAll();
	Head.Add("序号");
	Cols.Add(20);
	Head.Add("图名");
	Cols.Add(60);
	Head.Add("动态色");
	Cols.Add(20);
	m_listvec.InitCtrl(&Head, &Cols);

    m_listbmp.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)LVS_EX_FULLROWSELECT); 
    m_listvec.SendMessage(LVM_SETEXTENDEDLISTVIEWSTYLE, 0, (LPARAM)LVS_EX_FULLROWSELECT); 
	
	if (myanimate.picskind==0)
	{
		m_listbmp.ShowWindow(SW_SHOW);
		m_listvec.ShowWindow(SW_HIDE);
		for (int i=0;i<myanimate.piccount;i++)
		{
			CString tmp;
			tmp.Format("%d",i);
			Head.RemoveAll();
			Head.Add(tmp);
			Head.Add(myanimate.pics[i].picname);
			if (myanimate.pics[i].pickind==0) 
			{
				Head.Add("无");
			}else{
				Head.Add("有");
			}
		    int pos=m_listbmp.AddItem(&Head);
			m_listbmp.SetItemData(pos,myanimate.pics[i].piccolor);
		}
	//	m_listbmp.SetItemBackgndColor(WHITE,pos,0);
	//	m_listbmp.SetItemTextColor(BLACK,pos,0);
	}
	if (myanimate.picskind==1)
	{
		m_listbmp.ShowWindow(SW_HIDE);
		m_listvec.ShowWindow(SW_SHOW);
		for (int i=0;i<myanimate.piccount;i++)
		{
			CString tmp;
			tmp.Format("%d",i);
			Head.RemoveAll();
			Head.Add(tmp);
			Head.Add(myanimate.pics[i].picname);
			if (myanimate.pics[i].pickind==0) 
			{
				Head.Add("无");
			}else{
				Head.Add("有");
			}
		    int pos=m_listvec.AddItem(&Head);
			m_listvec.SetItemData(pos,myanimate.pics[i].piccolor);
		}
	//	m_listbmp.SetItemBackgndColor(WHITE,pos,0);
	//	m_listbmp.SetItemTextColor(BLACK,pos,0);
	}

	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 14
0
CTobCompiler::EToken CTobCompiler::GetString(CByteArray& bin)
{
    CByteArray temp;
    int c, d, e;
    for(;;)
    {
        if ((c = fgetc(m_fsrc)) < 0) break;
        if (c == '\n') ++m_line;
        else if (ms_tokentable[c] == 3)
        {
            m_err.Format("found invalid char 0x%02X in src file at %p", c, ftell(m_fsrc)-1);
            return ERR_NORMAL;
        }
        else if (c < ' ') continue;
        else if (c == '\'' || c == '"')
        {
            if ((d = fgetc(m_fsrc)) > 0)
            {
                if (d == ':')
                {
                    if ((d = fgetc(m_fsrc)) < 0) break;
                    e = GetSizeFromType(d);
                    if (e == -1)
                    {
                        m_err.Format("unknown type '%c' after ':'", d);
                        return ERR_NORMAL;
                    }

                    d = temp.GetSize();
                    for(int i = 0; i < e; ++i)
                        bin.Add(((BYTE*)&d)[i]);
                }
                else if (fseek(m_fsrc, -1, SEEK_CUR))
                {
                    m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                    return ERR_SEVERE;
                }
            }
            bin.Append(temp);
            if (c == '"')
                bin.Add(0);

            if (m_Option.bIgnoreCase)
                strlwr((LPSTR)bin.GetData());
            return SYM_STR;
        }
        else if (c == '\\')
        {
            if ((c = fgetc(m_fsrc)) < 0) break;
            switch(CHAR_UPPER(c))
            {
                case 'N': c = '\n';   break;
                case 'R': c = '\r';   break;
                case 'T': c = '\t';   break;
                case '0': c = '\0';   break;
                case '1': c = '\x01'; break;
                case '2': c = '\x02'; break;
                case '3': c = '\x03'; break;
                case '4': c = '\x04'; break;
                case '5': c = '\x05'; break;
                case '6': c = '\x06'; break;
                case '7': c = '\x07'; break;
                case '8': c = '\x08'; break;
                case '9': c = '\x09'; break;
                case 'A': c = '\x0a'; break;
                case 'B': c = '\x0b'; break;
                case 'C': c = '\x0c'; break;
                case 'D': c = '\x0d'; break;
                case 'E': c = '\x0e'; break;
                case 'F': c = '\x0f'; break;
                case 'X':
                {
                    if ((c = fgetc(m_fsrc)) < 0) goto end_;
                    BYTE b0 = ms_hextable[c];
                    if (b0 == 16)
                    {
                        m_err.Format("bad hex char 0x%02X after '\\x'", b0);
                        return ERR_NORMAL;
                    }
                    if ((c = fgetc(m_fsrc)) < 0) goto end_;
                    BYTE b1 = ms_hextable[c];
                    if (b1 == 16)
                    {
                        m_err.Format("bad hex char 0x%02X after '\\x'", b1);
                        return ERR_NORMAL;
                    }
                    temp.Add((BYTE)((b0<<4) + b1));
                }
            }
        }
        if (c >= 0x81)
        {
            if ((d = fgetc(m_fsrc)) < 0) break;
            if (d < 0x40)
            {
                if (fseek(m_fsrc, -1, SEEK_CUR))
                {
                    m_err.Format("can not seek src file at %p", ftell(m_fsrc));
                    return ERR_SEVERE;
                }
                m_err.Format("found half wide char at %p", ftell(m_fsrc)-1);
                return ERR_NORMAL;
            }
            temp.Add((BYTE)c);
            temp.Add((BYTE)d);
        }
        else
        {
            temp.Add((BYTE)c);
        }
    }
end_:
    if (!feof(m_fsrc))
        m_err.Format("can not read src file at %p", ftell(m_fsrc));
    else
        m_err = "bad string at the end of src file";
    return ERR_SEVERE;
}
Esempio n. 15
0
CTobCompiler::EToken CTobCompiler::CompilePass1()
{
    EToken r, LastToken;
    CString str, buf, sizebuf;
    CByteArray* bin;
    SValueType* val;
    SExpression* exp;

    for(;;)
    {
        BOOL bSkipGetToken = FALSE;
        if ((r = GetToken(str)) <= 0) return r;
_SkipGetToken:
        if (r == SYM_DEF)
        {
/*
            if (m_bin.GetSize() > 0)
            {
                m_err = "const token can not defined after data";
                return ERR_NORMAL;
            }
*/
            if ((r = GetToken(str)) < 0) return r;
            if (r != SYM_TOKEN)
            {
                m_err = "not found token after '@'";
                return ERR_NORMAL;
            }

            if (str == "_IGNORECASE")
            {
                m_Option.bIgnoreCase = TRUE;
                continue;
            }

            if ((r = GetToken(buf)) < 0) return r;
            if (r == SYM_BIN)
            {
                bin = new CByteArray;
                if ((r = GetBinary(*bin)) < 0) { delete bin; return r; }
                AddMap(m_binmap, str, bin);
            }
            else if (r == SYM_STR)
            {
                bin = new CByteArray;
                if ((r = GetString(*bin)) < 0) { delete bin; return r; }
                AddMap(m_binmap, str, bin);
            }
            else if (r == SYM_INT)
            {
                ULONG Length;
                BOOL bHex = (buf[0] == '0' && buf[1] == 'x');

                r = GetToken(sizebuf);
                LastToken = r;
                if (r == SYM_TYPE)
                {
                    r = GetToken(sizebuf);
                    if (r != SYM_TOKEN)
                    {
                        m_err = "not found type after ':'";
                        return ERR_NORMAL;
                    }

                    Length = GetSizeFromType(sizebuf[0]);
                    if (Length == -1)
                    {
                        m_err.Format("unknown type '%c' after ':'", sizebuf[0]);
                        return ERR_NORMAL;
                    }
                }
                else
                {
                    Length = -1;
                }
                val = new SValueType((int)strtoul(buf, NULL, bHex ? 16 : 10), Length);
                AddMap(m_valmap, str, val);

                if (Length == -1)
                    bSkipGetToken = TRUE;

                r = SYM_INT;
            }
            else if (r == SYM_FLOAT)
            {
                AddMap(m_valmap, str, new SValueType(atof(buf)));
            }
            else
            {
                m_err.Format("not found '[' or ''' or '\"' or number after '@%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }

            if (m_Option.bIgnoreCase)
                str.MakeUpper();

            if (str == "_DEFI")
            {
                if (r != SYM_INT || val->ival < 1 || val->ival > 4)
                {
                    m_err = "_DEFI must be 1/2/3/4";
                    return ERR_NORMAL;
                }
                m_Option.DefInt = val->ival;
            }
            else if (str == "_DEFF")
            {
                if (r != SYM_INT || val->ival != 4 && val->ival != 8)
                {
                    m_err = "_DEFF must be 4/8";
                    return ERR_NORMAL;
                }
                m_Option.DefFloat = val->ival;
            }
            else if (str == "_MOD")
            {
                if (r != SYM_INT)
                {
                    m_err = "_MOD must be number";
                    return ERR_NORMAL;
                }

                while (m_bin.GetSize() % val->ival)
                    m_bin.Add(0);
            }
            else if (str == "_INCLUDE")
            {
                FILE *fsrc;
                WCHAR szPath[MAX_PATH];
                CByteArray *bin;

                if (m_Option.bIgnoreCase)
                    str.MakeLower();

                if (!m_binmap.Lookup(str, bin))
                    continue;

                m_binmap.RemoveKey(str);

                MultiByteToWideChar(
                    CP_GB2312,
                    0,
                    (LPSTR)bin->GetData(),
                    -1,
                    szPath,
                    countof(szPath));

                delete bin;

                fsrc = m_fsrc;
                m_fsrc = _wfopen(szPath, L"rb");
                if (m_fsrc == NULL)
                {
                    m_fsrc = fsrc;
                    m_err.Format("can't open include file '%S'", szPath);
                    return ERR_SEVERE;
                }
                else
                {
                    EToken r;
                    for(;;)
                    {
                        r = CompilePass1();
                        if (r == ERR_EOF)
                            break;

                        if (r < 0)
                        {
                            if (!ErrorHandlerInternal(GetErrorString(m_err)))
                                break;
                        }

                        if (r == ERR_SEVERE)
                            break;
                    }

                    fclose(m_fsrc);
                    m_fsrc = fsrc;
                    if (r < 0)
                        return r;
                }
            }

            if (bSkipGetToken)
            {
                str = sizebuf;
                r = LastToken;
                goto _SkipGetToken;
            }
        }
        else if (r == SYM_BIN)
        {
            if ((r = GetBinary(m_bin)) < 0) return r;
        }
        else if (r == SYM_STR)
        {
            if ((r = GetString(m_bin)) < 0) return r;
        }
        else if (r == SYM_TOKEN)
        {
            if (!m_binmap.Lookup(str, bin))
            {
                m_err.Format("unknown token '%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }
            m_bin.Append(*bin);
        }
        else if (r == SYM_LABEL)
        {
            if ((r = GetToken(str)) < 0) return r;
            if (r != SYM_TOKEN)
            {
                m_err = "not found token after '#'";
                return ERR_NORMAL;
            }
            if (m_valmap.Lookup(str, val))
            {
                m_err.Format("already defined label token '%s'", (LPCTSTR)str);
                return ERR_NORMAL;
            }
            m_valmap.SetAt(str, new SValueType(m_bin.GetSize()));
        }
        else if (r == SYM_EXP_BEGIN)
        {
            int i = m_exparr.GetSize();
            do
            {
                int len = m_Option.DefInt;
                BOOL hastype = FALSE;
                exp = new SExpression(m_bin.GetSize(), m_line);
                for(;;)
                {
                    if ((r = GetToken(buf)) < 0)
                    {
                        delete exp;
                        return r;
                    }

                    if (r == SYM_TOKEN)
                    {
                        val = NULL;
                        if (!hastype && len > 0 && m_valmap.Lookup(buf, val) && val->isfloat)
                            len = -m_Option.DefFloat;
                        exp->m_item.Add(buf);
                        if (val != NULL && val->m_size != -1)
                            len = val->isfloat ? -val->m_size : val->m_size;
                    }
                    else if (r == SYM_ADD)
                    {
                        exp->m_item.Add("+");
                    }
                    else if (r == SYM_SUB)
                    {
                        exp->m_item.Add("-");
                    }
                    else if (r == SYM_DEF)
                    {
                        exp->m_item.Add("@");
                    }
                    else if (r == SYM_INT)
                    {
                        exp->m_item.Add(buf);
                    }
                    else if (r == SYM_FLOAT)
                    {
                        if (!hastype && len > 0)
                            len = -m_Option.DefFloat;
                        exp->m_item.Add(buf);
                    }
                    else if (r == SYM_TYPE)
                    {
                        int newlen;
                        if ((r = GetToken(buf)) < 0) { delete exp; return r; }
                        if (r != SYM_TOKEN)
                        {
                            delete exp;
                            m_err = "not found type after ':'";
                            return ERR_NORMAL;
                        }

                        newlen = GetSizeFromType(buf[0]);
                        if (newlen == -1)
                        {
                            delete exp;
                            m_err.Format("unknown type '%c' after ':'", buf[0]);
                            return ERR_NORMAL;
                        }

                        if (hastype && newlen != len)
                        {
                            delete exp;
                            m_err = "found different types in one expression";
                            return ERR_NORMAL;
                        }
                        hastype = TRUE;
                        len = newlen;
                    }
                    else if (r == SYM_BIN)
                    {
                        if (exp->m_item.GetSize() > 0)
                        {
                            delete exp;
                            m_err = "found different types in one expression";
                            return ERR_NORMAL;
                        }
                        if ((r = GetBinary(m_bin)) < 0) { delete exp; return r; }
                    }
                    else if (r == SYM_STR)
                    {
                        if (exp->m_item.GetSize() > 0)
                        {
                            delete exp;
                            m_err = "found different types in one expression";
                            return ERR_NORMAL;
                        }
                        if ((r = GetString(m_bin)) < 0) { delete exp; return r; }
                    }
                    else if (r == SYM_NEXT || r == SYM_EXP_END)
                    {
                        break;
                    }
                    else
                    {
                        delete exp;
                        m_err.Format("unknown or bad symbol1 '%s' in expression", (LPCTSTR)str);
                        return ERR_NORMAL;
                    }
                }
                if (exp->m_item.GetSize() <= 0)
                {
                    delete exp;
                }
                else
                {
                    exp->m_size = len;
                    m_exparr.Add(exp);
                    if (len < 0) len = -len;
                    while(len--)
                        m_bin.Add(0);
                }
            }
            while(r != SYM_EXP_END);
            for(int j = m_exparr.GetSize(); i < j; ++i)
                m_exparr[i]->m_self = m_bin.GetSize();
        }
        else
        {
            m_err.Format("unknown or bad symbol2 '%s'", (LPCTSTR)str);
            return ERR_NORMAL;
        }
    }
}
Esempio n. 16
0
CTobCompiler::EToken CTobCompiler::CompilePass1()
{
	EToken r;
	CString str, buf;
	CByteArray* bin = 0;

	for(;;)
	{
		if((r = GetToken(str)) <= 0) return r;
		if(r == SYM_KEY)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found keyword after '.'";
				return ERR_NORMAL;
			}
			if(str == "def")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found token after '.def'";
					return ERR_NORMAL;
				}
				if((r = GetToken(buf)) < 0) return r;
				if(r == SYM_BIN)
				{
					bin = new CByteArray;
					if((r = GetBinary(*bin)) < 0) { delete bin; return r; }
				}
				else if(r == SYM_STR)
				{
					if((r = GetString(buf, false)) < 0) return r;
					bin = new CByteArray;
					for(LPCTSTR p = buf; *p; ++p) bin->Add(*(U8*)p);
					if(r == SYM_STRING) bin->Add(0);
				}
				else if(r == SYM_STRING)
				{
					if((r = GetString(buf, true)) < 0) return r;
					bin = new CByteArray;
					for(LPCTSTR p = buf; *p; ++p) bin->Add(*(U8*)p);
					if(r == SYM_STRING) bin->Add(0);
				}
				else
				{
					m_err = "not found '[' or ''' or '\"' after '.def <token>''";
					return ERR_NORMAL;
				}
				m_defbin.SetAt(str, bin);
				bin = 0;
			}
			else if(str == "change")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_STR)
				{
					m_err = "not found ''' after '.change'";
					return ERR_NORMAL;
				}
				if((r = GetString(str, false)) < 0) return r;
				if( str.IsEmpty() || str.GetLength()>2 || str.GetLength() == 2 && (U8)str[0]<0x80)
				{
					m_err = "only one character is allowed after '.change'";
					return ERR_NORMAL;
				}
				U16 c = (U8)str[0];
				if(str.GetLength() == 2) c = (c<<8) + (U8)str[1];
				if((r = GetToken(str)) < 0) return r;
				if(r == SYM_BIN)
				{
					CByteArray tmp;
					if((r = GetBinary(tmp)) < 0) return r;
					buf.Empty();
					int i, n = tmp.GetSize();
					for(i = 0; i < n; ++i)
					{
						U8 b = tmp.GetAt(i);
						if(!b) break;
						buf += (TCHAR)b;
					}
				}
				else if(r == SYM_STR)
				{
					if((r = GetString(buf, false)) < 0) return r;
				}
				else if(r == SYM_STRING)
				{
					if((r = GetString(buf, true)) < 0) return r;
				}
				else
				{
					m_err = "not found ''' or '\"' after '.change <char>'";
					return ERR_NORMAL;
				}
				m_change.SetAt(c, buf);
			}
			else if(str == "bit")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.bit'";
					return ERR_NORMAL;
				}
				int bit = atoi(str);
				if(bit!=8 && bit!=16 && bit!=24 && bit!=32)
				{
					m_err = "only '.bit 8/16/24/32' is available";
					return ERR_NORMAL;
				}
				m_bit_i = bit;
			}
			else if(str == "maxc")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxc'";
					return ERR_NORMAL;
				}
				m_maxc = atoi(str);
			}
			else if(str == "maxw")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxw'";
					return ERR_NORMAL;
				}
				m_maxw = atoi(str);
			}
			else if(str == "maxs")
			{
				if((r = GetToken(str)) < 0) return r;
				if(r != SYM_TOKEN)
				{
					m_err = "not found parameter after '.maxs'";
					return ERR_NORMAL;
				}
				m_maxs = atoi(str);
			}
			else
			{
				m_err.Format("unknwon keyword '%s' after '.'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
		}
		else if(r == SYM_BIN)
		{
			if((r = GetBinary(m_bin)) < 0) return r;
		}
		else if(r == SYM_STR)
		{
			if((r = GetString(buf, false)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_STRING)
		{
			if((r = GetString(buf, true)) < 0) return r;
			for(LPCTSTR p=buf;* p; ++p) m_bin.Add(*(U8*)p);
			if(r == SYM_STRING) m_bin.Add(0);
		}
		else if(r == SYM_TOKEN)
		{
			if(!m_defbin.Lookup(str, bin))
			{
				m_err.Format("not defined token '%s'", (LPCTSTR)str);
				return ERR_NORMAL;
			}
			m_bin.Append(*bin);
			bin = 0;
		}
		else if(r == SYM_ADDR)
		{
			if((r = GetToken(str)) < 0)
				return r;
			SExpInfo* ti = new SExpInfo(m_bin.GetSize(), m_line);
			if(r == SYM_EXP_BEGIN)
			{
				for(;;)
				{
					if((r = GetToken(buf)) < 0)
					{
						delete ti;
						return r;
					}
					if(r == SYM_TOKEN || r == SYM_NUM)
						ti->m_item.Add(buf);
					else if(r == SYM_ADD)
						ti->m_item.Add("+");
					else if(r == SYM_SUB)
						ti->m_item.Add("-");
					else if(r == SYM_ADDR)
						ti->m_item.Add("@");
					else if(r == SYM_EXP_END)
						break;
					else
					{
						delete ti;
						m_err.Format("found unknown token '%s' in expression", (LPCTSTR)buf);
						return ERR_NORMAL;
					}
				}
			}
			else if(r == SYM_TOKEN)
				ti->m_item.Add(str);
			else
			{
				delete ti;
				m_err = "not found token or expression after '@'";
				return ERR_NORMAL;
			}
			m_exp.Add(ti);
			for(int i = m_bit_i/8; i--;)
				m_bin.Add(0);
		}
		else if(r == SYM_LABEL)
		{
			if((r = GetToken(str)) < 0) return r;
			if(r != SYM_TOKEN)
			{
				m_err = "not found label after '#'";
				return ERR_NORMAL;
			}
			m_label.SetAt(str, m_bin.GetSize());
		}
		else
		{
			m_err = "unknown or bad symbol";
			return ERR_NORMAL;
		}
	}
}
Esempio n. 17
0
/**
* @brief 从7张牌中分析出5张最大牌型
* @param bHandCards[]     要分析的手牌
* @param nCount           手牌张数
* @param bPublicCards[]   要分析公共牌
* @param nPublicCount     公共牌张数
* @param bResultCard[]    返回分析得到的数据牌
* @return 牌型
*/
int CUpGradeGameLogic::AnalysisCard(BYTE bHandCards[], int nHandCount, BYTE bPublicCards[], int nPublicCount, BYTE bResultCard[])
{
    if ((nHandCount + nPublicCount) != 7)
    {
        return 0;
    }
    
    int i, j;
    CByteArray arrCards;

    for (i = 0; i < nHandCount; i++)
    {
        arrCards.Add(bHandCards[i]);
    }
    
    for (i = 0; i < nPublicCount; i++)
    {
        arrCards.Add(bPublicCards[i]);
    }

    BYTE bCard[5] = {0};
    int nCardKind[21] = {0};

    //// 21种组成方法
    //BYTE bIndex[21][5] = {0, 1, 2, 3, 4, \
    //                      0, 1, 2, 3, 5, \
    //                      0, 1, 2, 3, 6, \
    //                      0, 1, 2, 4, 5, \
    //                      0, 1, 2, 4, 6, \
    //                      0, 1, 2, 5, 6, \
    //                      0, 1, 3, 4, 5, \
    //                      0, 1, 3, 4, 6, \
    //                      0, 1, 3, 5, 6, \
    //                      0, 1, 4, 5, 6, \
    //                      0, 2, 3, 4, 5, \
    //                      0, 2, 3, 4, 6, \
    //                      0, 2, 3, 5, 6, \
    //                      0, 2, 4, 5, 6, \
    //                      0, 3, 4, 5, 6, \
    //                      1, 2, 3, 4, 5, \
    //                      1, 2, 3, 4, 6, \
    //                      1, 2, 3, 5, 6, \
    //                      1, 2, 4, 5, 6, \
    //                      1, 3, 4, 5, 6, \
    //                      2, 3, 4, 5, 6, \
    //                     };

	// 21种组成方法
	BYTE bIndex[21][7] = {0, 1, 2, 3, 4, 5, 6,
		                  0, 1, 2, 3, 5, 4, 6,
		                  0, 1, 2, 3, 6, 4, 5,
		                  0, 1, 2, 4, 5, 3, 6,
		                  0, 1, 2, 4, 6, 3, 5,
		                  0, 1, 2, 5, 6, 3, 4,
		                  0, 1, 3, 4, 5, 2, 6,
		                  0, 1, 3, 4, 6, 2, 5,
		                  0, 1, 3, 5, 6, 2, 4, 
		                  0, 1, 4, 5, 6, 2, 3, 
		                  0, 2, 3, 4, 5, 1, 6, 
		                  0, 2, 3, 4, 6, 1, 5, 
		                  0, 2, 3, 5, 6, 1, 4, 
		                  0, 2, 4, 5, 6, 1, 3, 
		                  0, 3, 4, 5, 6, 1, 2, 
		                  1, 2, 3, 4, 5, 0, 6, 
		                  1, 2, 3, 4, 6, 0, 5, 
		                  1, 2, 3, 5, 6, 0, 4, 
		                  1, 2, 4, 5, 6, 0, 3, 
		                  1, 3, 4, 5, 6, 0, 2, 
		                  2, 3, 4, 5, 6, 0, 1
						 };

    for (i = 0; i < 21; i++)
    {	
        for (j = 0; j < 5; j++)
        {
            // 按牌下标取出5张牌
            bCard[j] = arrCards.GetAt(bIndex[i][j]);
        }
      
        // 获取牌型
        nCardKind[i] = GetCardShape(bCard, 5);

		//CString str;
		//str.Format("dxh: 第%d种方法, 牌型: %d",  i, nCardKind[i]);
		//OutputDebugString(str);
    }

    // 取最大牌型位置
    int nMax = 0;
    for (i = 1; i < 21; i++)
    {
        if (nCardKind[i] > nCardKind[nMax])
        {
            nMax = i;
        }
    }

    BYTE bCompareCard1[5], bCompareCard2[5];
    int nCompareMax = nMax;

    // 找出最大牌型后, 再找出相同牌型最大牌组合(牌型一样情况下, 则会比大小, 所以这里就需要取最大的相同的牌型)
    for (i = 0; i < 21; i++)
    {
        if (i == nMax)
        {
            continue;
        }

        for (j = 0; j < 5; j++)
        {
            bCompareCard1[j] = arrCards.GetAt(bIndex[i][j]);
            bCompareCard2[j] = arrCards.GetAt(bIndex[nCompareMax][j]);
        }
        
        // 比牌(-1:输, 0:和, 1:赢)
        if (CompareCard(bCompareCard1, 5, bCompareCard2, 5) > 0)
        {
            nCompareMax = i;
        }
    }

    // 从7张手牌中取出5终最终牌型
    for (i = 0; i < 7; i++)
    {
        bResultCard[i] = arrCards.GetAt(bIndex[nCompareMax][i]);
    }

	CString str;
	str.Format("dxh: 当前最大牌型索引: %d, 牌型ID:%d", nCompareMax, nCardKind[nCompareMax]);
	OutputDebugString(str);

    return nCardKind[nCompareMax];
}
/*static*/
HRESULT CSheetConfigGSD::GetExtUserParams(IExtUserParam* pParam, ExtParam* pExtParam)
{
	if (pParam == NULL || pExtParam == NULL)
		return E_POINTER;

	BSTR    sName;
	USES_CONVERSION;
    HRESULT hr = pParam->get_Description(&sName);
    if (SUCCEEDED(hr)) {
		pExtParam->SetDescription(sName);
		::SysFreeString(sName);
    }
	else	{
		delete pExtParam;
		return hr;
	}

    long lTmp = 0;
    long lOffset = 0;
    hr = pParam->get_Offset(&lOffset);
    if (SUCCEEDED(hr)) {
		pExtParam->SetByteOffset(lOffset);
    }
	else	{
		delete pExtParam;
		return hr;
	}
    BOOL bConst = FALSE;
    BOOL bVarEnum = FALSE;
    BOOL bVarRange = FALSE;
    BOOL bBitArea = FALSE;
    hr = pParam->get_IsConstantParam(&bConst);
    if (SUCCEEDED(hr)) {
		pExtParam->SetIfConstant(bConst);
	}
	else	{
		delete pExtParam;
		return hr;
	}

    if (bConst)
    {
        CComVariant vtBytes;
        hr = pParam->get_ConstPrmBytes(&vtBytes);
        if (SUCCEEDED(hr)) {
			HRESULT     hr;
			// is it what we expected in VARIANT?
            ASSERT(vtBytes.vt == (VT_UI1 | VT_ARRAY));
			if (vtBytes.vt == (VT_UI1 | VT_ARRAY))
			{
				// now show values
				SAFEARRAY   *psaBytes = vtBytes.parray;

				long    lBound = 0, uBound = 0;
				hr = ::SafeArrayGetLBound(psaBytes, 1, &lBound);
				_ASSERTE(SUCCEEDED(hr));
				hr = ::SafeArrayGetUBound(psaBytes, 1, &uBound);
				_ASSERTE(SUCCEEDED(hr));
				// loop thru all objects in this level:
				CByteArray octets;
				octets.RemoveAll();
				for (long i = lBound; i <= uBound; i++)
				{
					BYTE    ucVal;
					hr = ::SafeArrayGetElement(psaBytes, &i, &ucVal);
					_ASSERTE(SUCCEEDED(hr));
					if (FAILED(hr)) {
						continue;
					}
					octets.Add(ucVal);
				}// next byte
				pExtParam->SetConstantBytes(octets.GetData(), octets.GetSize());
			}
		}
        pExtParam->SetParamType(Array);
        return S_OK;
    }

    hr = pParam->get_DefaultValue(&lTmp);
    if (SUCCEEDED(hr)) {
		pExtParam->SetDefaultValue(lTmp);
    }
    hr = pParam->get_IsVariableEnumParam(&bVarEnum);
    if (SUCCEEDED(hr)) {
		//pExtParam->SetIfVariableEnum(bVarEnum);
    }
	else	{
		delete pExtParam;
		return hr;
	}
    hr = pParam->get_IsVariableMinMaxParam(&bVarRange);
    if (SUCCEEDED(hr)) {
        hr = pParam->get_MinValue(&lTmp);
        if (SUCCEEDED(hr)) {
			pExtParam->SetLowerValue(lTmp);
        }
        hr = pParam->get_MaxValue(&lTmp);
        if (SUCCEEDED(hr)) {
			pExtParam->SetUpperValue(lTmp);
        }
    }
	else	{
		delete pExtParam;
		return hr;
	}
    hr = pParam->get_IsBitArea(&bBitArea);
    if (SUCCEEDED(hr)) {
		pExtParam->SetIfBitArea(bBitArea);
        // show bit area params
        hr = pParam->get_BitAreaStart(&lTmp);
        if (SUCCEEDED(hr)) {
			pExtParam->SetBitAreaStart(lTmp);
		}
        hr = pParam->get_BitAreaLength(&lTmp);
        if (SUCCEEDED(hr)) {
			pExtParam->SetBitAreaLength(lTmp);
        }
    }
	else	{
		delete pExtParam;
		return hr;
	}

	CComVariant vtValues, vtNames;
	hr = pParam->NamedEnumValues(&vtValues, &vtNames);
	if (SUCCEEDED(hr)) {
		HRESULT hr;
		// is it what we expected in VARIANT?
        ASSERT(vtValues.vt == (VT_I4 | VT_ARRAY));
        ASSERT(vtNames.vt == (VT_BSTR | VT_ARRAY));
		if (   (vtValues.vt == (VT_I4 | VT_ARRAY))
			&& (vtNames.vt == (VT_BSTR | VT_ARRAY))  )
		{
			// now show values and texts
			SAFEARRAY   *psaValues = vtValues.parray;
			SAFEARRAY   *psaNames = vtNames.parray;

			long    lBound = 0, uBound = 0;
			hr = ::SafeArrayGetLBound(psaValues, 1, &lBound);
			_ASSERTE(SUCCEEDED(hr));
			hr = ::SafeArrayGetUBound(psaValues, 1, &uBound);
			_ASSERTE(SUCCEEDED(hr));
			// loop thru all objects in this level:
			for (long i = lBound; i <= uBound; i++)
			{
				LONG    lVal;
				BSTR    sName;
				hr = ::SafeArrayGetElement(psaValues, &i, &lVal);
				_ASSERTE(SUCCEEDED(hr));
				hr = ::SafeArrayGetElement(psaNames, &i, &sName);
				_ASSERTE(SUCCEEDED(hr));
				if (FAILED(hr)) {
					continue;
				}
				NamedEnumValues* pElement = new NamedEnumValues;
				pElement->Value = lVal;
				pElement->szName = sName;
				pExtParam->AddNamedEnumVal(pElement);
                SysFreeString(sName);
			}// next
		}
	}// end if (SUCCEEDED(hr))

    if (bVarEnum && !pExtParam->IsVariableEnumParam())
    {
        CComVariant vtEnums;
        hr = pParam->EnumValues(&vtEnums);
        if (SUCCEEDED(hr)) {
            ASSERT(vtEnums.vt == (VT_I4 | VT_ARRAY));
			if (vtEnums.vt == (VT_I4 | VT_ARRAY))	{
				// now show values and texts
				SAFEARRAY   *psaValues = vtEnums.parray;

				long    lBound = 0, uBound = 0;
				hr = ::SafeArrayGetLBound(psaValues, 1, &lBound);
				_ASSERTE(SUCCEEDED(hr));
				hr = ::SafeArrayGetUBound(psaValues, 1, &uBound);
				_ASSERTE(SUCCEEDED(hr));
				// loop thru all objects in this level:
				for (long i = lBound; i <= uBound; i++)
				{
					LONG    lVal;
					CString szName;
					hr = ::SafeArrayGetElement(psaValues, &i, &lVal);
					_ASSERTE(SUCCEEDED(hr));
					if (FAILED(hr)) {
						continue;
					}
					szName.Format(_T("%d"), lVal);

					NamedEnumValues* pElement = new NamedEnumValues;
					pElement->Value = lVal;
					pElement->szName = szName;
					pExtParam->AddNamedEnumVal(pElement);
				} //next i
			}// end if
        }// end if
    }// end if

    SetExtParamType(pParam,pExtParam);
    return S_OK;
}