Sign in to follow this  
chillypacman

Manipulating an LPCWSTR?

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this