Hinweis
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, sich anzumelden oder das Verzeichnis zu wechseln.
Für den Zugriff auf diese Seite ist eine Autorisierung erforderlich. Sie können versuchen, das Verzeichnis zu wechseln.
Changes the working drive.
int _chdrive(
int drive
);
Parameters
- drive
An integer from 1 through 26 that specifies the working drive (1=A, 2=B, and so forth).
Return Value
Zero (0) if the working drive was changed successfully; otherwise, -1.
Remarks
If drive is not 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 is not 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 at MSDN Library.
The _chdrive function changes only the working drive; _chdir changes the working directory.
Requirements
Routine |
Required header |
|---|---|
_chdrive |
<direct.h> |
For more information, see Compatibility.
Example
See the example for _getdrive.
.NET Framework Equivalent
System::Environment::CurrentDirectory
See Also
Reference
Change History
Date |
History |
Reason |
|---|---|---|
|
October 2010 |
Specified the range of the drive parameter. Remarked that _chdrive is not thread-safe. |
Information enhancement. |