You're asking the wrong guy if you want a real answer, but I would imagine that it would be better to declare it outside of the loop, since it is just being used over and over.
PHP Code:
for(i=0;i<index;i++)
    {
        
char val[100] = "his";
        
itoa(ithei20);
        
strcat(valthei);
        
MessageBox(NULL,thei,thei,MB_OK);
    
//Get the caption of the item based on its index
    
SendMessage(chCB_GETLBTEXTi, (LPARAM)buffer);
    
//Add the item to the registry key
    
RegSetValueEx(regkeyval0REG_SZ, (LPBYTE)bufferstrlen(buffer)+1);
         
delete [] val//added
    

I imagine that would be better for memory usage, but don't take my word as fact