> Windows All > Windows All win32
Read Usenet Home | Disclaimer | Report Adult Posts

Windows Usenet Topics on Windows All win32



Windows All win32 - "SHCreateDirectory() problem" in Windows All


Old 12-15-2003   #1
..r.. ..unde..
 
Default SHCreateDirectory() problem

I have a directory on my C drive named "C:\xxxx and
am calling SHCreateDirectory() like this:

int res = SHCreateDirectory (NULL, "C:\xxxx\pub\download\windows\dotnet");

When I call FormatMessage with res as the dwMessageId I get the result:

"The specified path is invalid."

I also tried appending a "\" at the end of the new path name and got the
same result.

The MSDN do***entation claims that this function is supposed to create
the intermediate folders (which don't exist when I call the function).

Can anyone see an error in this call?

Regards
Chris Saunders
chris.saunders@sympatico.ca


 
Old 12-15-2003   #2
..m ..bins..
 
Default Re: SHCreateDirectory() problem

Replace each \ in the string with \\. This is a basic C++ mistake which your
compiler should have warned you about.

--
Tim Robinson (MVP, Windows SDK)


"Chris Saunders" <chris.saunders@sympatico.cawrote in message
news:1j7Db.3180$Ve.403440@news20.bellglobal.com...
Quote:
I have a directory on my C drive named "C:\xxxx and
am calling SHCreateDirectory() like this:

int res = SHCreateDirectory (NULL, "C:\xxxx\pub\download\windows\dotnet");

When I call FormatMessage with res as the dwMessageId I get the result:

"The specified path is invalid."

I also tried appending a "\" at the end of the new path name and got the
same result.

The MSDN do***entation claims that this function is supposed to create
the intermediate folders (which don't exist when I call the function).

Can anyone see an error in this call?

Regards
Chris Saunders
chris.saunders@sympatico.ca

 
Old 12-15-2003   #3
..r.. ..unde..
 
Default Re: SHCreateDirectory() problem

Thanks for the suggestion Tim.

I tried it a still got the same error return. I wrote another
function that uses CreateDirectory to build the subdirectory
bit by bit. It works but I would have preferred using the
shell function.

Regards
Chris Saunders
chris.saunders@sympatico.ca

"Tim Robinson" <tim.at.gaat.freeserve.co.uk@invalid.comwrote in message
news:brjogn$3en7t$1@ID-103400.news.uni-berlin.de...
Quote:
Replace each \ in the string with \\. This is a basic C++ mistake which
your
Quote:
compiler should have warned you about.

 
Old 12-16-2003   #4
.... ..ekhm..
 
Default Re: SHCreateDirectory() problem

"Chris Saunders" <chris.saunders@sympatico.cawrote in message
news:1j7Db.3180$Ve.403440@news20.bellglobal.com...
Quote:
I have a directory on my C drive named "C:\xxxx and
am calling SHCreateDirectory() like this:

int res = SHCreateDirectory (NULL, "C:\xxxx\pub\download\windows\dotnet");

When I call FormatMessage with res as the dwMessageId I get the result:

"The specified path is invalid."

I also tried appending a "\" at the end of the new path name and got the
same result.

The MSDN do***entation claims that this function is supposed to create
the intermediate folders (which don't exist when I call the function).

Can anyone see an error in this call?
You're passing the wrong string. It must be wide character string. I don't
know how it succeeded to pass compilation. Correct code is:

int res = SHCreateDirectory(NULL,
L"C:\\xxxx\\pub\\download\\windows\\dotnet");


 

Thread Tools
Display Modes





Powered by vBulletin®
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.