几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】problem using getfilename (http://www.dimcax.com/hust/showthread.php?t=18077)

yang686526 2009-05-06 11:02 PM

【转帖】problem using getfilename
 
problem using getfilename
problem using getfilename
i have just upgraded to vs2005 and downloaded the new libraries.
now i have encountered a problem with the 2.5.1 libraries:
(lpctstr)pdb->getfilename().c_str();
returns "c"
i was trying to pass the filename as a cstring object to a function.
however, if i do:
afxmessagebox(pdb->getfilename()) it shows the full path.
so what has changed here?
andrew
if i remove the .c_str() from my code then it works ok. but this code was fine for vc6 libraries.
andrew
i think the effect is caused not by changing compiler but by changed meaning of lpctstr (unicode / char)
pdb->getfilename().c_str()
returns pointer to odchar (unicode string)
if lpctstr is char* than explicit cast to it casts wchar_t* to char* - you see single character.
if lpctstr is wchar_t* than it works ok.
after removing .c_str() it works always because
odstring operator (const char*) correctly converts unicode string to char. or odstring operator (const wchar_t*) is invoked depending on meaning of lpctstr.
sergey slezkin


所有的时间均为北京时间。 现在的时间是 03:43 AM.