What tpes to use for char array?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • academic

    #1

    What tpes to use for char array?

    This is from something I wrote 15 years ago.

    Haven't use c since then

    Wanted to use it now so I cut and pasted into VS2005 on WinXP

    Now I can't seem to get the types OK

    GetModuleFileNa me requires LPWCH for szModulePath

    What are the compatible types??



    Thanks



    char szModulePath[SIZE_OF_PATH];

    GetModuleFileNa me(happThisInst ance, szModulePath, sizeof(szModule Path));


    //Remove the FileName from the full pathname

    PSTR pstr = szModulePath + lstrlen(szModul ePath) - 1;

    //note: '\\' is the character \ The first \ is a c language escape character

    while ((*pstr != '\\') && (*pstr != ':') && (pstr >= szModulePath)) pstr--;

    pstr++;

    *pstr=(char)0;


  • David Lowndes

    #2
    Re: What tpes to use for char array?

    >GetModuleFileN ame requires LPWCH for szModulePath[color=blue]
    >
    >What are the compatible types??[/color]

    You could use TCHAR - which is a wide (16-bit) character in a Unicode
    build, or a char in a non-Unicode build.

    Your existing code should work relatively easily if you change the
    (default) setting of your new VS2005 project from Unicode.

    Dave

    Comment

    • Bruno van Dooren

      #3
      Re: What tpes to use for char array?

      > This is from something I wrote 15 years ago.[color=blue]
      >
      > Haven't use c since then
      >
      > Wanted to use it now so I cut and pasted into VS2005 on WinXP
      >
      > Now I can't seem to get the types OK
      >
      > GetModuleFileNa me requires LPWCH for szModulePath
      >
      > What are the compatible types??[/color]

      VS2005 has the unicode character set as its default, which is not compatible
      with your usage of CHAR*
      To solve your problem you have to revert the character set to ASCII.
      you do that by setting the 'character set' property in your general project
      properties to 'not set'.

      Note: if you use precompiled headers, you have to make sure that it is
      recompiled after your change, otherwise the compiler will still see the
      unicode definition of GetModuleFileNa me.

      --

      Kind regards,
      Bruno.
      bruno_nos_pam_v an_dooren@hotma il.com
      Remove only "_nos_pam"


      Comment

      Working...