DosChDir

This call defines the current directory for the requesting process.

Syntax

DosChDir (DirName, Reserved)

Parameters

DirName (PSZ) - input : Address of the ASCIIZ directory path name.

Reserved (ULONG) - input : Reserved and must be set to zero.

Return Code

rc (USHORT) - return

Return code descriptions are:

0 NO_ERROR

2 ERROR_FILE_NOT_FOUND

3 ERROR_PATH_NOT_FOUND

5 ERROR_ACCESS_DENIED

8 ERROR_NOT_ENOUGH_MEMORY

26 ERROR_NOT_DOS_DISK

87 ERROR_INVALID_PARAMETER

108 ERROR_DRIVE_LOCKED

206 ERROR_FILENAME_EXCED_RANGE

Remarks

The directory path is not changed if any member of the path does not exist. The current directory changes only for the requesting process.

For FSDs, the case of the current directory is set according to the DirName passed in, not according to the case of the directories on disk. For example, if the directory “c:\bin” is created and DosChDir is called with DirName “c:\bin”, the current directory returned by DosQCurDir will be “c:\bin”.

Programs running without the NEWFILES bit set are allowed to DosChDir to a non-8.3 filename format directory.

DosQSysInfo must be used by an application to determine the maximum path length supported by OS/2. The returned value should be used to dynamically allocate buffers that are to be used to store paths.

Example Code

C Binding

#define INCL_DOSFILEMGR
USHORT rc = DosChDir(DirName, Reserved);
PSZ DirName; /* Directory path name *
ULONG 0; /* Reserved (must be zero) */
USHORT rc; /* return code */

This example changes directories to \os2\system.

#define INCL_DOSFILEMGR
#define PATH "\\os2\\system"
#define RESERVED 0L
USHORT rc;
rc = DosChDir(PATH, RESERVED);

MASM Binding

EXTRN DosChDir:FAR
INCL_DOSFILEMGR EQU 1
PUSH@ ASCIIZ DirName ;Directory path name string
PUSH DWORD 0 ;Reserved (must be zero)
CALL DosChDir

Returns WORD

Note

Text based on http://www.edm2.com/index.php/DosChDir

Family API
DOS	Process Manager	DosBeep DosExit DosSleep DosExecPgm
File Manager	DosChDir DosChgFilePtr DosClose DosDelete DosDupHandle DosMkDir DosMove DosQCurDir DosQCurDisk DosSetFileMode DosOpen DosQFileInfo DosRead DosQFileMode DosQFSInfo DosQVerify DosRmDir DosSelectDisk DosFindClose DosFindFirst DosFindNext DosSetFileInfo DosSetVerify DosWrite DosFileLocks DosSetFHandState DosNewSize DosBufReset DosQFHandState DosSetFSinfo DosShutdown
Memory Manager	DosFreeSeg DosSubAlloc DosSubFree DosSubSet DosAllocHuge DosAllocSeg DosReallocHuge DosReallocSeg DosGetHugeShift DosCreateCSAlias
NLS	DosCaseMap DosGetCtryInfo DosGetDBCSEv DosSetCtryCode DosGetCollate DosGetMessage DosInsMessage DosPutMessage
Date and Time	DosSetDateTime DosGetDateTime
Devices	DosDevConfig DosDevIOCtl DosDevIOCtl2
Signals	DosHoldSignal DosSetSigHandler
Misc	BadDynLink DosGetEnv DosGetMachineMode DosGetVersion DosError DosErrClass DosSetVec
KBD	KbdCharIn KbdFlushBuffer KbdGetStatus KbdSetStatus KbdStringIn KbdPeek
VIO	VioGetBuf VioGetConfig VioGetCurPos VioGetCurType VioGetPhysBuf VioReadCellStr VioReadCharStr VioScrollUp VioScrollDn VioScrollLf VioScrollRt VioScrUnLock VioSetCurPos VioSetCurType VioSetMode VioGetMode VioShowBuf VioWrtCellStr VioWrtCharStr VioWrtCharStrAtt VioWrtNAttr VioWrtNCell VioWrtNChar VioWrtTTY VioScrLock VioPopUp
Tools	BIND
Modules	DOSCALLS.DLL VIOCALLS.DLL KBDCALLS.DLL MSG.DLL
Libraries	API.LIB OS2386.LIB FAPI.LIB DOSCALLS.LIB SUBCALLS.LIB