Jump to content
  • Advertisement
Sign in to follow this  
chillypacman

Manipulating an LPCWSTR?

This topic is 4121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Lets say I have an LPCWSTR like L"models/bones/skull.x". how can I seperate the path to skull.x and "skull.x"? That is how can I make L"models/bones/skull.x" into L"models/bones/" L"skull.x"? I appreciate any help :)

Share this post


Link to post
Share on other sites
Advertisement
PathFindFileName(). This function returns a pointer to the location in your string that the filename starts. It doesnt take constant strings so if you can use LPWSTR that would be better. If not, you can perform a const_cast.

Share this post


Link to post
Share on other sites
Hi Chillypacman -

I personally would use std::wstring for this.

You could do like path.rfind('/') to find the last path delimiter of the string then use two std::wstring::substr calls to separate them out.

Share this post


Link to post
Share on other sites
Quote:
Original post by Colin Jeanne
PathFindFileName(). This function returns a pointer to the location in your string that the filename starts. It doesnt take constant strings so if you can use LPWSTR that would be better. If not, you can perform a const_cast.


I tried that but I'm getting a link2019 error,

error LNK2019: unresolved external symbol __imp__PathFindFileNameW@4 referenced in function "bool __cdecl ObjectSetup(void)" (?ObjectSetup@@YA_NXZ)

I'm including "Shlwapi.h" since that is where PathFindFileName is.

Share this post


Link to post
Share on other sites
Make sure you're also linking 'shlwapi.lib' into your executable. By including the header the symbol is declared, but without linking in the library it's never defined.

Cheers!

Share this post


Link to post
Share on other sites
Quote:
Original post by jwalsh
Make sure you're also linking 'shlwapi.lib' into your executable. By including the header the symbol is declared, but without linking in the library it's never defined.

Cheers!


bleh, sometimes I wonder how I can get anything done :P

thanks :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!