Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong marshalling for pszVerb in Shell32.IFolderView2.InvokeVerbOnSelection() #456

Closed
l-eugine opened this issue Apr 22, 2024 · 1 comment

Comments

@l-eugine
Copy link

Describe the bug and how to reproduce

Call Shell32.IFolderView2.InvokeVerbOnSelection() with non-empty verb.

On such call nothing happens, no error is reported.

The issue is with current declaration of this method

		/// <summary>Invokes the given verb on the current selection.</summary>
		/// <param name="pszVerb">
		/// <para>Type: <c>LPCSTR</c></para>
		/// <para>A pointer to a Unicode string containing a verb.</para>
		/// </param>
		/// <remarks>If pszVerb is <c>NULL</c>, then the default verb is invoked on the selection.</remarks>
		// https://docs.microsoft.com/en-us/windows/desktop/api/shobjidl_core/nf-shobjidl_core-ifolderview2-invokeverbonselection
		// HRESULT InvokeVerbOnSelection( LPCSTR pszVerb );
		void InvokeVerbOnSelection([In, MarshalAs(UnmanagedType.LPWStr)] string? pszVerb);

As it said in comment, pszVerb should be LPCSTR, so proper marshalling should be MarshalAs(UnmanagedType.LPStr)] not UnmanagedType.LPWStr

With UnmanagedType.LPStr everything works as expected.

text in MSDN help is also misleading, stating that Unicode string is expected, while they clearly have it defined as ANSI string.

@dahall
Copy link
Owner

dahall commented Apr 23, 2024

Fixed for 4.0.1

@dahall dahall closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants