DWORD Problems

I'm geting these errors on this code, andI can;t seem to figure it out. Any help is appreciated. Thank you.

warning C4800: 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)

error C2440: '=' : cannot convert from 'DWORD *' to 'unsigned int'

IntelliSense: a value of type "DWORD *" cannot be assigned to an entity of type "unsigned int"

THE CODE.....
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using namespace std;
typedef vector<WIN32_FIND_DATA> tFoundFilesVector;
std::wstring LastWriteTime;  
int getFileList(wstring filespec, tFoundFilesVector &foundFiles)
{
    WIN32_FIND_DATA findData;
    HANDLE h;
    bool validResult=true;
    int numFoundFiles = 0;
	h = FindFirstFile(filespec.c_str(), &findData);
 
    if (h == INVALID_HANDLE_VALUE)
        return 0;
 
    while (validResult)
    {
        numFoundFiles++;
        foundFiles.push_back(findData);
        validResult = FindNextFile(h, &findData);
    }
    return numFoundFiles;
}
 
void showFileAge(tFoundFilesVector &fileList)
{
    unsigned fileTime, curTime, age;
    tFoundFilesVector::iterator iter;
	FILETIME ftNow; //added
	__int64 nFileSize;
    CoFileTimeNow(&ftNow);
    curTime = ((INT64) &ftNow.dwHighDateTime << 32) + &ftNow.dwLowDateTime;
 
    for (iter=fileList.begin(); iter<fileList.end(); iter++)
    {
        fileTime = ((INT64)iter->ftLastWriteTime.dwHighDateTime << 32) + iter->ftLastWriteTime.dwLowDateTime;
 
        age = curTime - fileTime;
 
        cout << "FILE: '" << iter->cFileName << "', AGE: " << (INT64)age/10000000UL << " seconds" << endl;
    }
}
 
int main()
{
    string fileSpec = "*.*";
    tFoundFilesVector foundFiles;
    tFoundFilesVector::iterator iter;
 
    int foundCount = 0;
 
    getFileList(L"*.c??", foundFiles);
    getFileList(L"*.h", foundFiles);
 
    foundCount = foundFiles.size();
    if (foundCount)
    {
        cout << "Found "<<foundCount<<" matching files.\n";
        showFileAge(foundFiles);
    }
    return 0;
}

1. The warning is just that. A warning. You can get rid of it by writing '<whatever it is that returns a BOOL> == TRUE'.

2. You are trying to assign the pointer to a DWORD value to a variable of type unsigned int (or DWORD as well). Either cast the DWORD pointer, or dereference the pointer.

3. Same as 2.
Thank you, BOOL fixed but having a heck of a time with the DWORD. Maybe a visual on this?
Well I don't even know where in your code the problem is. Your debugger should be telling the line. Possible errors would be:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//A prototype:
void MyFunc(DWORD myParam);
...

DWORD myVal;
....
//Error:
MyFunc(&myVal);

DWORD *pmyVal;
//Error too:
MyFunc(pmyVal);

//Corrections to the above:
MyFunc(myVal);
MyFunc(*pmyVal);
Thank you for your help. This fixed it.

OLD curTime = ((INT64) &ftNow.dwHighDateTime << 32) + &ftNow.dwLowDateTime;
NEW curTime = ((INT64) ftNow.dwHighDateTime << 32) + ftNow.dwLowDateTime;
Topic archived. No new replies allowed.