-
September 10th, 2004, 06:59 AM
#1
SHCreateDirectory not found
Hi,
I want to use SHCreateDirectory to create a directory, line C:\D1\D2\D3, etc. but I cannot find it. The compiler gives me the undeclared indentifier (C2065) error. According to MSDN:
Minimum DLL Version shell32.dll version 5.0 or later Custom Implementation No Header shlobj.h Import library shell32.lib Minimum operating systems Windows 2000
My shell32.dll version is 6.0.2800.1106, I am running on WinXP, with VisualC++ 6.0, SP6, and of course I include shlobj.h. But the funny thing is that there is no SHCreateDirectory in that header. I searched all the headers on my PC and there is not such method.
What is this?
-
September 10th, 2004, 07:03 AM
#2
Re: SHCreateDirectory not found
I think there isn't. Try SHCreateDirectoryEx
Har Har
-
September 10th, 2004, 07:27 AM
#3
Re: SHCreateDirectory not found
Originally Posted by PadexArt
I think there isn't. Try SHCreateDirectoryEx
So is the case of SHCreateDirectoryEx... What did you think?
I was hoping to avoid downloading from Microsoft after I saw yesterday "I, Robot".
-
September 10th, 2004, 07:30 AM
#4
Re: SHCreateDirectory not found
Originally Posted by cilu
So is the case of SHCreateDirectoryEx... What did you think?
True. I've just checked it and it is missing too. I've pointed it out as SHCreateDirectory doesn't even show up in MSDN Oct 2001.
Har Har
-
September 10th, 2004, 07:35 AM
#5
Re: SHCreateDirectory not found
Originally Posted by cilu
Then forward declare it and use LoadLibrary(...)/GetProcAddress(...)
-
September 10th, 2004, 07:43 AM
#6
Re: SHCreateDirectory not found
Originally Posted by Mick
Then forward declare it and use LoadLibrary(...)/GetProcAddress(...)
Well Mick, now you're coming with something... Thanks. I will do that.
-
September 10th, 2004, 08:12 AM
#7
still not working
I did this:
Code:
typedef int (WINAPI* lpfnSHCreateDirectory)( HWND hwnd, LPCWSTR pszPath );
void Tests()
{
HMODULE hShell32Dll = ::LoadLibrary( _T("shell32.dll") );
lpfnSHCreateDirectory lpFn = NULL;
if( hShell32Dll )
{
lpFn = (lpfnSHCreateDirectory)GetProcAddress( hShell32Dll, "SHCreateDirectory" );
if ( lpFn )
{
int ret = lpFn( NULL, (LPCWSTR)"C:\\D1\\D2\\D3");
switch(ret)
{
case ERROR_BAD_PATHNAME :
TRACE("The pszPath parameter was set to a relative path.\n");
break;
case ERROR_FILENAME_EXCED_RANGE :
TRACE("The path pointed to by pszPath is too long. \n");
break;
case ERROR_FILE_EXISTS :
TRACE("The directory exists. \n");
break;
case ERROR_ALREADY_EXISTS :
TRACE("The directory exists. \n");
break;
case ERROR_CANCELLED :
default:
TRACE("unknown\n");
break;
}
}
}
if( hShell32Dll != (HMODULE)INVALID_HANDLE_VALUE )
FreeLibrary(hShell32Dll);
}
But it gives me ERROR_BAD_PATHNAME, saying that "The pszPath parameter was set to a relative path". I also tried with a simple "C:\\D1" and it returning the same error... And I don't figure out why...
-
September 10th, 2004, 07:03 AM
#8
Re: SHCreateDirectory not found
Download the latest Platfrom SDK from msdn.microsoft.com
-
July 17th, 2022, 05:26 PM
#9
Re: SHCreateDirectory not found
I am getting this error when I compile my code.
I had already included the function SHGetFolderPath
sucessfully, but when I added SHCreateDirectory(NULL, p_path)
it stopped compiling. I have the following headers
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include "Format.h"
#include <wchar.h>
#include <stdio.h>
#include <shlwapi.h> // for SHGetFolderPath function
#include <shlobj.h> // for SHGetFolderPath and SHCreateDirectory function
//*************************************************************************************************************************
#pragma comment(lib, "shlwapi")
#pragma comment(lib, "shell32")
Any suggestions?
-
September 1st, 2022, 02:49 PM
#10
Re: SHCreateDirectory not found
Originally Posted by existenceproduct
I am getting this dmvfoam error when I compile my code.
I had already included the function SHGetFolderPath
sucessfully, but when I added SHCreateDirectory(NULL, p_path)
it stopped compiling. I have the following headers
#include <windows.h>
#include <stdlib.h>
#include <malloc.h>
#include <memory.h>
#include <tchar.h>
#include "Format.h"
#include <wchar.h>
#include <stdio.h>
#include <shlwapi.h> // for SHGetFolderPath function
#include <shlobj.h> // for SHGetFolderPath and SHCreateDirectory function
//*************************************************************************************************************************
#pragma comment(lib, "shlwapi")
#pragma comment(lib, "shell32")
Any suggestions?
no solution to this
-
September 2nd, 2022, 02:08 AM
#11
Re: SHCreateDirectory not found
Originally Posted by existenceproduct
no solution to this
There is nothing to solve, since we don't see the code casing the error, nor have we any info about what the error was.
Victor Nijegorodov
-
July 18th, 2022, 01:31 AM
#12
Re: SHCreateDirectory not found
Please, provide the exact error message together with the error code, as well as some info about your system, like Windows OS, VS OS
Victor Nijegorodov
-
August 10th, 2022, 06:22 PM
#13
Re: SHCreateDirectory not found
Originally Posted by VictorN
Please, provide the exact error message together with the error code, as well as some info about your system, like Windows OS, VS OS
i already share the exact code
-
August 11th, 2022, 12:55 AM
#14
Re: SHCreateDirectory not found
Originally Posted by existenceproduct
i already share the exact code
You didn't.
You only posted the #includes with #pragmas and meaningless description.
So no code, no exact error message.
Victor Nijegorodov
-
July 18th, 2022, 03:29 AM
#15
Re: SHCreateDirectory not found
Well excluding "format.h", those headers compile fine for me with VS2022.
But without seeing the code that gives the compiler errors...
This test code compiles OK with the given header:
Code:
int main() {
HWND hwnd {};
SHCreateDirectory(hwnd, L"path");
}
Note that the 2nd param is of type PCWSTR ie a wide (unicode) string and not an ASCII one.
Last edited by 2kaud; July 18th, 2022 at 03:42 AM.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|