CreateDirectoryEx Function

Declare Function CreateDirectoryEx Lib "kernel32.dll" Alias "CreateDirectoryExA" (ByVal lpTemplateDirectory As String, ByVal lpNewDirectory As String, lpSecurityAttributes As SECURITY_ATTRIBUTES) As Long

Platforms

Description & Usage

CreateDirectoryEx creates a new directory on a disk. It also allows you to specify the security attributes of the newly created directory, if the operating system supports it. The newly created directory will inherit most of its attributes (except security) from a template directory specified by the function. For example, the new directory will have the same file attributes as the template directory.

Return Value

If an error occured, the function returns 0 (use GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

lpTemplateDirectory
The name of the directory to use as an attribute template for creating the new directory.
lpNewDirectory
The name of the new directory to create.
lpSecurityAttributes
Windows NT, 2000: The security attributes to assign to the newly created directory. Windows 95, 98, CE: This parameter is ignored.

Example

' This code is licensed according to the terms and conditions listed here.

' Create the new directory C:\Dummy\NewDir and
' give it default security attributes.  It will inherit its properties from the
' directory C:\Recycled (the "Recycle Bin") -- although this won't be another
' recycle bin, it will have the Hidden and System attributes.
Dim secattr As SECURITY_ATTRIBUTES  ' security attributes structure
Dim retval As Long  ' return value

' Set the desired security attributes
secattr.nLength = Len(secattr)  ' size of the structure
secattr.lpSecurityDescriptor = 0  ' default (normal) level of security
secattr.bInheritHandle = 1  ' this is the default setting

' Create the directory, using C:\Recycled as the template.
retval = CreateDirectoryEx("C:\Recycled", "C:\Dummy\NewDir", secattr)

See Also

CreateDirectory, RemoveDirectory

Category

Files

Go back to the alphabetical Function listing.
Go back to the Reference section index.


Last Modified: March 19, 2000
This page is copyright © 1999 Paul Kuliniewicz. Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/c/createdirectory.html