WindowsApi:GetCurrentDirectory
현재 디렉터리 위치를 얻어온다.
Warning
프로그램을 하다 보면 각종 설정 파일이나 이미지,사운드 등 리소스 파일 또는 DB, DLL 및 Library 등 각종 파일을 시스템 폴더나 혹은 프로그램이 설치된 폴더아래에 두고 사용하는 경우가 많다. 아니 거의 대부분이 아닐까? 대게 프로그램이 설치되면 실행파일(exe)이 있는폴더가 프로그램 설치폴더가 된다. 그런데 프로그램이 실행되면 대부분의 경우에는 CurrentDirectory 와 실행파일(exe)이 있는폴더가 같지만 그렇지 않는 경우도 많다. 그리고 무엇보다 중요한것은 CurrentDirectory는 얼마든지 바뀔 수 있다는 것이다.
CurrentDirectory가 바뀌는 경우:
- SetCurrentDirectory() 또는 SetCurrentDir(VCL)로 현재디렉토리를 직접 바꾸는 경우.
- SaveDialog() 나 OpenDialog()등으로 Dialog를 Execute해서 파일을 선택, 확인한 경우 (주의).
GetCurrentDirectory()
로 현재 디렉터리 위치를 얻어올 경우 FILE dialog에서 경로를 변경시 다른 경로가 나올 우려가 있다. 따라서 가능한 GetModuleFileName()를 사용해야 한다.
Run-Time Library Reference
Variable | Required header | Compatibility |
| stdlib.h | Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition, Windows NT 4.0, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003, Windows Server 2003 |