4.2. Creating and Deleting

Typically a user creates a directory either with the File Manager or with the mkdir command. There are many reasons that you may do the same thing inside of an application. For example, if you are writing an application that installs another application or a set of data files, you will need to create directories to hold the files that you are installing.

Listing 4.1 uses the CreateDirectory function to create a new directory.

Code Listing 4.1. Creating a new directory (Page of )
 // dircreat.cpp #include <windows.h> #include <iostream.h> void main() { char s[MAX_PATH]; BOOL success; // get name of directory cout << "Enter path/name of new directory: "; cin >> s; success = CreateDirectory(s, 0); if (!success) cout ...

Get Win32 System Services: The Heart of Windows® 98 and Windows® 2000 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.