389,453 Members | 6,428 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 389,453 IT Pros & Developers. It's quick & easy.

What tpes to use for char array?

academic
P: n/a
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
Share this Question
Share on Google+
2 Replies


David Lowndes
P: n/a
>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

Bruno van Dooren
P: n/a
> 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.
bruno_nos_pam_van_dooren@hotmail.com
Remove only "_nos_pam"
Feb 17 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.