I tried to get the current directory using GetCurrentDirectory()
but it returns the dir till there is aa space ' ' on the dir like if the current dir is
C:\Users\Mix Prog\prog1\Debug
then it return only till
C:\Users\Mix
Can someone point out why it happens like that? Here is my code:
TCHAR priv[BUFSIZE];
DWORD dwRet;
dwRet = GetCurrentDirectory(BUFSIZE, priv);
TCHAR command[BUFSIZE] = L"cmd.exe /C ";
wcscat_s(command, priv);
I suggest that (instead of using wscat_s) you change your code to something like this:
wsprintf (command, "cmd.exe /C \"%s\"", priv);
As others have pointed out, I suspect priv is correct in your code (ie if you look with a debugger the contents are correct), but cmd has not interpreted it correctly because of the space.
In windows API we can get directory from below code
// Get Current Dir
#define BUFSIZE MAX_PATH
TCHAR myDir[BUFSIZE];
DWORD dwRet;
dwRet = GetCurrentDirectory(BUFSIZE, myDir);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.