[python-win32] win32file.CreateSymbolicLink and SYMLINK_FLAG_DIRECTORY

Tim Roberts timr at probo.com
Tue Jun 16 19:17:23 CEST 2009


Devin Jeanpierre wrote:
> I'm new to pywin32 development, but wanted to toy with creating
> symlinks (and related new things) with a similar API to the current os
> module. The documentation in pywin32 states that the only flag is
> "SYMLINK_FLAG_DIRECTORY" (MSDN docs state that in the C++ API, the
> only flag is "SYMBOLIC_LINK_FLAG_DIRECTORY"). I don't know where to
> find it; the examples that were provided showed flags being in the
> same module, such as "win32pdh.PERF_DETAIL_WIZARD", but there is no
> win32file.SYMLINK_FLAG_DIRECTORY on my install, nor is there a
> win32file.SYMBOLIC_LINK_FLAG_DIRECTORY (in fact, nothing of the form
> win32file.SYM*). I could find no dedicated constants/flags module or
> submodule. I would appreciate some help finding the constant (for now,
> I am using the magic number 1 as described in the MSDN docs).
>   

Many Windows constants are gathered in win32con.  Give that a try.  I
can't test it myself, because my version of pywin32 does not include the
CreateSymbolicLink API at all.  If that fails, then you are safe in
using the value 1.  That's what's defined in the SDK header files.

If you are considering distributing this, remember that
CreateSymbolicLink requires at least Vista.  It is not present in XP.

> Also, it appears that CreateSymbolicLink raises an exception in some
> failure circumstances (when the location that the symlink would be is
> already taken up by something), but not others (when the user doesn't
> have the appropriate permissions for creating symbolic links).
>   

Hmm.  Does the API return anything in those cases?

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list