Skip to content

Latest commit

 

History

History
68 lines (48 loc) · 2.62 KB

File metadata and controls

68 lines (48 loc) · 2.62 KB
description title ms.date api_name api_location api_type topic_type f1_keywords helpviewer_keywords ms.assetid
Learn more about: _chdrive
_chdrive
4/2/2020
_chdrive
_o__chdrive
msvcrt.dll
msvcr80.dll
msvcr90.dll
msvcr100.dll
msvcr100_clr0400.dll
msvcr110.dll
msvcr110_clr0400.dll
msvcr120.dll
msvcr120_clr0400.dll
ucrtbase.dll
api-ms-win-crt-filesystem-l1-1-0.dll
DLLExport
apiref
chdrive
_chdrive
drives, changing
_chdrive function
chdrive function
212a1a4b-4fa8-444e-9677-7fca4c8c47e3

_chdrive

Changes the current working drive.

Important

This API cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported in Universal Windows Platform apps.

Syntax

int _chdrive(
   int drive
);

Parameters

drive
An integer from 1 through 26 that specifies the current working drive (1=A, 2=B, and so forth).

Return value

Zero (0) if the current working drive was changed successfully; otherwise, -1.

Remarks

If drive isn't in the range from 1 through 26, the invalid-parameter handler is invoked as described in Parameter validation. If execution is allowed to continue, the _chdrive function returns -1, errno is set to EACCES, and _doserrno is set to ERROR_INVALID_DRIVE.

The _chdrive function isn't thread-safe because it depends on the SetCurrentDirectory function, which is itself not thread-safe. To use _chdrive safely in a multi-threaded application, you must provide your own thread synchronization. For more information, see SetCurrentDirectory.

The _chdrive function changes only the current working drive; _chdir changes the current working directory.

By default, this function's global state is scoped to the application. To change this behavior, see Global state in the CRT.

Requirements

Routine Required header
_chdrive <direct.h>

For more information, see Compatibility.

Example

See the example for _getdrive.

See also

Directory control
_chdir, _wchdir
_fullpath, _wfullpath
_getcwd, _wgetcwd
_getdrive
_mkdir, _wmkdir
_rmdir, _wrmdir
system, _wsystem