The CreateHardLink function documentation reads:
lpSecurityAttributes
Reserved; must be NULL.
...however the declaration [currently] reads:
[DllImport("kernel32.dll", EntryPoint = "CreateHardLink")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool CreateHardLink(
[In] [MarshalAs(UnmanagedType.LPTStr)] string lpFileName, [In] [MarshalAs(UnmanagedType.LPTStr)] string lpExistingFileName,
ref SECURITY_ATTRIBUTES lpSecurityAttributes);
...which means I can not use IntPtr.Zero as the last parameter. I also can't use null, because SECURITY_ATTRIBUTES is a struct and the compiler wants me to initialize a ref parameter.
It would be better to declare it as:
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool CreateHardLink(string newFileName, string existingFileName, IntPtr securityAttributes);
The CreateHardLink function documentation reads:
...however the declaration [currently] reads:
...which means I can not use
IntPtr.Zeroas the last parameter. I also can't usenull, because SECURITY_ATTRIBUTES is astructand the compiler wants me to initialize arefparameter.It would be better to declare it as: