471,109 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,109 software developers and data experts.

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

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;
Feb 17 '06 #1
2 3415
>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
Feb 17 '06 #2
> 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.
br**********************@hotmail.com
Remove only "_nos_pam"
Feb 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

16 posts views Thread by cppaddict | last post: by
3 posts views Thread by FroxX | last post: by
18 posts views Thread by Matt | last post: by
15 posts views Thread by damian birchler | last post: by
13 posts views Thread by chellappa | last post: by
5 posts views Thread by Omats.Z | last post: by
4 posts views Thread by Bobrick | last post: by
3 posts views Thread by chutsu | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.