hi there ... here it is.
i realized that some barcodes are longer(10bytes)
like 00 00 00 00 00 00 00 00 00 00
but some are shorter(8bytes)
like 00 00 00 00 00 00 00 00
and there rest of the two bytes appeared to be cc cc in the edit box.
how do i terminate the shorter strings or each string with a null? how
will the program know which barcodes are shorter?
do i have to rewrite everything now?
please help.
****************on OpenKey***********
dwBufLen = MY_BUFSIZE;
DWORD dwRc=0;
BYTE szKeyName[MY_BUFSIZE];
BYTE szBar[MY_BUFSIZE];
dwRc = RegOpenKeyEX(etc etc etc ...)
....
.....
****
/////get supplier's name
RegQueryValueEx(hKey, TEXT("lpRegKey"

, 0, NULL, (LPBYTE)szKeyName,
&dwBufLen);
CString szTemp = "F&N";
CListBox *lbProductsNames = (CListBox*) GetDlgItem(IDC_LIST_CARDS);
int iSelected = lbProductsNames->GetCurSel();
lbProductsNames->GetText(iSelected, szTemp);
m_txtName.SetWindowText(szTemp);
UpdateData(FALSE);
///////get barcodes
RegQueryValueEx(hKey, "Bar", 0, NULL, (LPBYTE)szBar, &dwBufLen);
CString cBar;
cBar.Format(_T("%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%"

,
szBar[0], szBar[1], szBar[2], szBar[3], szBar[4], szBar[5], szBar[6],
szBar[7]),szBar[8],szBar[9],;
m_txtBar.SetWindowText(cATR);
// Close the registry key.
RegCloseKey( hKey );
return S_OK;
}
void CRegistryProductDlg::OnButtonSelect()
{
// TODO: Add your control notification handler code here
CListBox *lbptr = (CListBox *)GetDlgItem(IDC_LIST_PRODUCT);
int iListIndex;
long lResult = 0;
char cKeyName,cBar;
iListIndex = lbptr->GetCurSel();
if(iListIndex==LB_ERR) {
MessageBox("No Selection.Please select a product.", "Select",
MB_OK|MB_ICONEXCLAMATION);
}
else {
lbptr->GetText(iListIndex, cKeyName);
lResult = OpenKey(cKeyName, cBar);
if (lResult != NO_ERROR){
MessageBox("Open key failed", "Error", MB_OK);
}
else{
HKEY hKey;
TCHAR szProductType[MY_BUFSIZE]; //#define MY_BUFSIZE 64
DWORD dwBufLen = MY_BUFSIZE;
LONG lRet;
char buffer[150];
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("KeyName"

,
0,
KEY_ALL_ACCESS,
&hKey)!= ERROR_SUCCESS)
return;
lRet = RegQueryValueEx(hKey,
TEXT("KeyName"

,
NULL,
NULL,
(LPBYTE)szProductType,
&dwBufLen);
sprintf(buffer, "%2x %2x %2x %2x %2x %2x %2x %2x%2x %2x",
szProductType[0], szProductType[1], szProductType[2],
szProductType[3], szProductType[4], szProductType[5],
szProductType[6], szProductType[7], szProductType[8],
szProductType[9]);
//i tried to replace the sprintf with for loop
int len = strlen(szProductType), k = 0;
for(int i = 0; i < len; i++)
{
k += sprintf(buffer+k, "%2x", szProductType
);
}
m_txtProduct.SetWindowText(buffer);
RegCloseKey(hKey);
if(lRet!= ERROR_SUCCESS) return ;
}
}
}