Create the directory as a temp directory. GetTempPath()
will give you the path to your temp directory:
DWORD WINAPI GetTempPath(
_In_ DWORD nBufferLength,
_Out_ LPTSTR lpBuffer
) ;
Use that to create a unique temp file name with GetTempFileName()
:
UINT WINAPI GetTempFileName(
_In_ LPCTSTR lpPathName,
_In_ LPCTSTR lpPrefixString,
_In_ UINT uUnique,
_Out_ LPTSTR lpTempFileName
) ;
That will, depending on how it's invoked, either
- create an empty file with a unique name (uUnique is zero), or
- just return the unique name (uUnique is non-zero).
Then create a directory of that name in the temp directory. When you've got it into the condition you want it WRT attributes (hidden, etc.), then move it into its final location with MoveFile()
or MoveFileEx()
.
Of course, it might be easier just to get the temp path as above, and iteratively try to create a subdirectory, generating a unique temp name using a GUID or the current date/time and appending an incrementing suffix. Once the directory is created, then set its attributes and proceed as above to move it to its final location.