-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Milestone
Description
I have the following existing code:
[DllImport(Lib.Kernel32, SetLastError = true, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool Process32FirstW(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
VS suggests me to convert it to LibraryImport
, there is also an option to use W
suffix:
I've chosen that and it created:
[LibraryImport(Lib.Kernel32, EntryPoint = "Process32FirstWW", SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public static partial bool Process32FirstW(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
Obviously there is no such Process32FirstWW
entrypoint. I don't know at which logic VS suggests sometimes only A
prefix, sometimes only W
prefix and sometimes no prefix at all. But seeing that there must be a logic somehow, the logic leads to invalid code at this point. For some people its obvious, for other people it might not. However I think that IF VS suggests to use W
suffix which seems to be based on some logic, it must be correct, or it should just not show any suffix option at all (which VS is doing for some other pinvokes).