i kinda stuck api getdrivetype()
. every time api returns me drive_no_root_dir
, passing drive letters "c:\" etc. primary drive "c:\" api returns same thing.
i have called getlogicaldrives()
before retrieve.
os: winxp sp3, ntfs file system
code: compiler vs2005
int main() { bool folder; string * filename; char individualdrive[4],alldrives[100]; memset(alldrives,0,100); getlogicaldrivestringsa(100,alldrives); for(int i=0;(i<100)&&(alldrives[i]);i+=4) { memset(individualdrive,0,4); strncpy(individualdrive,alldrives+i,4); //extracting individual drive strings. if(drive_fixed == getdrivetypew((lpcwstr)individualdrive)) getfile((system::string*)individualdrive, filename,folder); } return 0; }
without code have guess. guesses are:
- you failed escape
\
"c:\\"
. - you passing ansi string unicode version of api, or vice versa.
it's hard see how api fail unless coding error of nature.
having added code question clear second of these bullet points explanation. passing ansi string data unicode api , this, of course, fails.
to fix best switching code use unicode strings.
in addition unicode/ansi issues, think buffer handling code suspect. don't know why assuming 4 characters drive. think possible getlogicaldrivestrings return un-mapped drives.
Comments
Post a Comment