BOOL IsDir(LPCSTR szDir) { DWORD dwAttrib; if ((dwAttrib = GetFileAttributes(szDir)) == 0xFFFFFFFF) return FALSE; return (dwAttrib & FILE_ATTRIBUTE_DIRECTORY); } BOOL MakeSymLink(LPCSTR szSrc, LPCSTR szTarget) { const DWORD flags = IsDir(szTarget) ? SYMBOLIC_LINK_FLAG_DIRECTORY : SYMBOLIC_LINK_FLAG_FILE; if (!CreateSymbolicLink(szSrc, szTarget, flags)) { const DWORD dwError = GetLastError(); fprintf(stderr, "Could not make symbolic link because %d\n", dwError); return FALSE; } return TRUE; }
Programming Tips - How can I programatically make a symbolic link?
Date: 2015apr3
Language: C/C++
Platform: win32
Q. How can I programatically make a symbolic link?
A.