What tpes to use for char array?

  • Thread starter Thread starter academic
  • Start date Start date
A

academic

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

GetModuleFileName requires LPWCH for szModulePath

What are the compatible types??



Thanks



char szModulePath[SIZE_OF_PATH];

GetModuleFileName(happThisInstance, szModulePath, sizeof(szModulePath));


//Remove the FileName from the full pathname

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

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

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

pstr++;

*pstr=(char)0;
 
GetModuleFileName requires LPWCH for szModulePath
What are the compatible types??

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

GetModuleFileName requires LPWCH for szModulePath

What are the compatible types??

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 GetModuleFileName.

--

Kind regards,
Bruno.
(e-mail address removed)
Remove only "_nos_pam"
 
Back
Top