Quote Originally Posted by juanpast
I try to do this obtaining the title of the explorer and searching selected file but crasshes:

Code:
void myDlg::OnButtonSearch() 
{
  char szWindow[1000];
  EnumWindows(SearchWin,(LPARAM)szWindow);
}

BOOL CALLBACK SearchWin(HWND hWnd,LPARAM lpParam) {    
  SendMessage(hWnd, WM_GETTEXT, 1000, (LPARAM) lpParam); 
  char sText[1000];
  strcpy(sText,(char*)lpParam);
  if(strcmp(sText,"Title of explorer") == 0) {
    EnumChildWindows(hWnd,SearchChildWin,NULL);
  }  
  return TRUE; 
}

BOOL CALLBACK SearchChildWin(HWND hWnd,LPARAM lpParam) {
  char sClass[1000];
  GetClassName(hWnd,sClass,1000);  
  if(strcmp(sClass,"SysListView32") == 0) {
    LVITEM *iItem = new LVITEM;
    iItem->iSubItem = 0;
    iItem->cchTextMax = 255;
    iItem->pszText = new char[iItem->cchTextMax + 1];
    int nItem = SendMessage(hWnd, LVM_GETITEMCOUNT, 0, 0);
    bool bFound = false;
    int i=0;
    while(!bFound && i < nItem) {
      int nStatus = SendMessage(hWnd,LVM_GETITEMSTATE,i,LVIS_SELECTED);
      if(nStatus == LVIS_SELECTED) {
        SendMessage(hWnd,LVM_GETITEMTEXT, i, (LPARAM)iItem);
        bFound = true;        
      } else i++;
    }    
  }  
  return TRUE;
}


Someone know what this code crasshes in the red line??
Notice the bold part of the code.

Regards,
Usman.