6 Replies Latest reply on Oct 6, 2015 11:15 AM by rtinker

    How to use GetProjectPath (and other A_UTF16Char) properly?

    PSuuraho Newcomer

      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));

      }

      }