4 Replies Latest reply: May 16, 2013 9:14 AM by Zac Lam RSS

    How to use GetProjectPath (and other A_UTF16Char) properly?

    PSuuraho Community Member

      Hi there,

       

      I'm trying to get the current project path and store it to wstring variable, and later convert it to A_Char to show it on reportinfo.

       

      Following code works correctly on Windows 7 64bit and project path is displayed with ReportInfo dialog box, but on macosx 10.6.8, projectPathW.length() is always nonzero even when no project is opened. And ReportInfo always shows empty string.

       

       

      AEGP_ProjectH project;

      AEGP_MemHandle pathH;

       

      suites.ProjSuite5()->AEGP_GetProjectByIndex(0, &project);

       

      if (project) {

      err = suites.ProjSuite5()->AEGP_GetProjectPath(project, &pathH);

      if (!err)

      {

      A_UTF16Char *pathText;

       

      err = suites.MemorySuite1()->AEGP_LockMemHandle(pathH, (void**)&pathText);

       

      if (!err)

      {

      wstring projectPathW((wchar_t*)pathText);

      if (projectPathW.length() == 0)

      {

      suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id,"empty string");

      }

      else

      {

      char *fileName = (char *)malloc( AEGP_MAX_PATH_SIZE );

      wcstombs( fileName, projectPathW.c_str(), AEGP_MAX_PATH_SIZE );

      suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id,fileName);

      free(fileName);

      }

      }

      suites.MemorySuite1()->AEGP_UnlockMemHandle(pathH);

      ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(pathH));

      }

      }