A miracle. For some reason, it works.
Aha, the PROPERTIES for my project show:
Character set: Use Unicode. If I switch to non-uni, will I have to change all wprintf back to printf? The mystery deepens.
Maybe the char I code locally is char. But the function call is using TCHAR which translates to wchar_t?? Mismatch?
Edit: Turning off unicode now causes compile errors. Hmmm... Had to change all wprintf to printf. Now onto this whole unicode thing for GetDriveStrings. The nightmare continues.....
Code:
WIN32_FIND_DATA myfind;
HANDLE hfd;
DWORD dx = 200;
TCHAR tcurrdir[300];
char currdir[300];
char szer = {0};
char nl = {10};
char bslsh[2] = {92, 0};
x = GetCurrentDirectory(dx, tcurrdir);
printf("tcurrdir ");
for ( x = 0; x < 50; x++) {
wprintf(L" %X %c %X", tcurrdir[x], tcurrdir[x], &tcurrdir[x]);
}
wprintf(L"currdir at run time %s %c", tcurrdir, nl);
// currdir[0] = szer;
// currdir[1] = szer;
tcurrdir[0] = szer;
tcurrdir[1] = szer;
lstrcat (tcurrdir, L"D:\\");
// lstrcat (currdir, bslsh);
lstrcat (tcurrdir, L"oedbx\\");
// lstrcat (currdir, bslsh);
// lstrcat (currdir, "jlewandowsk2");
// lstrcat (currdir, bslsh);
// lstrcat (currdir, "*");
wprintf(L"DIR built %s %c", tcurrdir, nl);
x = SetCurrentDirectory(tcurrdir);
x = GetCurrentDirectory(dx, tcurrdir);
wprintf(L"SET DIR %s %c", tcurrdir, nl);
printf("%c", nl);
lstrcat (tcurrdir, L"\\*");
myfind.cFileName[0] = szer;
hfd = FindFirstFile(tcurrdir, &myfind);
printf("handle %d ", hfd);
wprintf(L"FIRST file-dir %s %c", myfind.cFileName, nl);
while ( FindNextFile (hfd, &myfind) ) {
wprintf(L"while loop %c", nl);
wprintf(L"NEXT file-dir %s %c", myfind.cFileName, nl);
}
FindClose(hfd);
getchar();
return 0;