Skip to content

Instantly share code, notes, and snippets.

@JubbaSmail
Created November 13, 2014 10:12
Show Gist options
  • Select an option

  • Save JubbaSmail/2830c65d24c767e9de82 to your computer and use it in GitHub Desktop.

Select an option

Save JubbaSmail/2830c65d24c767e9de82 to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <stdio.h>
#if define UNICODE
#define SetCurrentDirectory SetCurrentDirectoryW
#define GetCurrentDirectory GetCurrentDirectoryW
#else
#define SetCurrentDirectory SetCurrentDirectoryA
#define GetCurrentDirectory GetCurrentDirectoryA
#endif
int main(int argc, LPTSTR argv[])
{
if (argc != 2) {
fprintf(stderr, "Usage: mycd dirName\n");
return 1;
}
SetCurrentDirectory(argv[1]);
CHAR pwdBuffer[MAX_PATH];
DWORD x = GetCurrentDirectory(MAX_PATH, pwdBuffer);
printf(pwdBuffer);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment