NO

Author Topic: WIN32_FIND_DATA 64 bit woes  (Read 6145 times)

gromit

  • Guest
WIN32_FIND_DATA 64 bit woes
« on: July 07, 2013, 09:12:47 AM »
Hi All
The Following Code
attempts to list subfolders in foldername
It is running a 32 bit prog designated as compile in 32 bit on a 64 bit machine
The entire proram works fine on wince for a pda and I am now converting / rewriting to suit my 64bit laptop

My first problem is that on searcing for folders I get none they are clearly there
and are listed as files but not singled out as folders

Note all folders files are text files and are generated on a 32 bit pda

The 4 questions that arise for me are

1 Can I in some way confirm that my prog is in fact being compiled as a 32 bit app
did I click on the right option at the outset

2 Would I be better to compile to 64 bit instead

3 if I have to use Wow64DisableWow64FsRedirection( _Out_  PVOID *OldValue);etc
 does anyone know what I should be putting in for the _Out_  PVOID *OldValue

4 Is there an alternative way to traverse the folders in c that will overcome the 64 bit problem

Code: [Select]
/**********************************************************************************

static void DisplayFoldersNamesToCombo(wchar_t *foldername)

called to collect folder names and diasplay to combo at top of list view
Errors   : None
 ----------------------------------------------------------------------------*/
 static void DisplayFoldersNamesToCombo(HWND h,int ctrlid,wchar_t *foldername)

{
SendMessage(GetDlgItem(h,ctrlid), CB_RESETCONTENT,0,0);

wchar_t pathname[255];
wcscpy(pathname,foldername);

//add the search filter
wcscat(pathname,L"*.*");
//Wow64DisableWow64FsRedirection( _Out_  PVOID *OldValue);


 WIN32_FIND_DATA  lpFindFileData;
 
   HANDLE findhandle = FindFirstFile(pathname,&lpFindFileData);


       if (findhandle==INVALID_HANDLE_VALUE)
            {
                MessageBox(NULL, L"Directory Not Found", L"Error", MB_OK);
                return;
           
}



//after findfirst successfully retrieved search handle
   if (lpFindFileData.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY)
{



SendDlgItemMessage(h, ctrlid, CB_ADDSTRING,(WPARAM) 0, (LPARAM)lpFindFileData.cFileName);

}
// now use FinndNext
while (FindNextFile(findhandle,&lpFindFileData)==TRUE)
        {
 if (lpFindFileData.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY)
{

SendDlgItemMessage(h, ctrlid, CB_ADDSTRING, 0, (LPARAM)lpFindFileData.cFileName);
//MessageBox(NULL,lpFindFileData.cFileName ,L"FindNextFile", MB_OK | MB_ICONINFORMATION);


}

      }


FindClose(findhandle);
//Wow64RevertWow64FsRedirection( _In_  PVOID OldValue);

}
« Last Edit: July 07, 2013, 09:26:38 AM by Stefan Pendl »

gromit

  • Guest
Re: WIN32_FIND_DATA 64 bit woes
« Reply #1 on: July 07, 2013, 09:51:02 PM »
Thanks to all for viewing my problem here

I have now solved it and it was far simpler than I thought

My pda using wince would not use DlgDirListComboBox

static void DisplayFoldersNamesToCombo(HWND h,int ctrlid,wchar_t *foldername)

{

SendMessage(GetDlgItem(h,ctrlid), CB_RESETCONTENT,0,0);
DlgDirListComboBox(h,foldername,ctrlid,0,DDL_EXCLUSIVE   |DDL_DIRECTORY   );

}

This is far simpler and returns my folder names
1 small drawback is that they are displayed surrounded by square brackets.
I am sure I can strip them away
 Hope this helps someone else
gromit