]>
cygwin.com Git - cygwin-apps/setup.git/blob - mklink2.cc
8 static const char *cvsid
=
12 /* This part of the code must be in C because the C++ interface to COM
17 make_link_2 (char const *exepath
, char const *args
, char const *icon
, char const *lname
)
21 WCHAR widepath
[MAX_PATH
];
23 CoCreateInstance (&CLSID_ShellLink
, NULL
,
24 CLSCTX_INPROC_SERVER
, &IID_IShellLink
, (LPVOID
*) & sl
);
25 sl
->lpVtbl
->QueryInterface (sl
, &IID_IPersistFile
, (void **) &pf
);
27 sl
->lpVtbl
->SetPath (sl
, exepath
);
28 sl
->lpVtbl
->SetArguments (sl
, args
);
29 sl
->lpVtbl
->SetIconLocation (sl
, icon
, 0);
31 MultiByteToWideChar (CP_ACP
, 0, lname
, -1, widepath
, MAX_PATH
);
32 pf
->lpVtbl
->Save (pf
, widepath
, TRUE
);
34 pf
->lpVtbl
->Release (pf
);
35 sl
->lpVtbl
->Release (sl
);
38 #define SYMLINK_COOKIE "!<symlink>"
40 /* Predicate: file is not currently in existence.
41 * A file race can occur otherwise.
45 mkcygsymlink (const char *from
, const char *to
)
49 HANDLE h
= CreateFileA (from
, GENERIC_WRITE
, 0, 0, CREATE_NEW
,
50 FILE_ATTRIBUTE_NORMAL
, 0);
51 if (h
== INVALID_HANDLE_VALUE
)
53 strcpy (buf
, SYMLINK_COOKIE
);
55 if (WriteFile (h
, buf
, strlen (buf
) + 1, &w
, NULL
))
58 SetFileAttributesA (from
, FILE_ATTRIBUTE_SYSTEM
);
This page took 0.036953 seconds and 5 git commands to generate.