heftymouse
heftymouse
Explore posts from servers
CC#
Created by heftymouse on 10/10/2023 in #help
✅ CoTaskMemFree on a buffer returned by CsWin32
that worked, thanks a ton
14 replies
CC#
Created by heftymouse on 10/10/2023 in #help
✅ CoTaskMemFree on a buffer returned by CsWin32
this complains about not being able to cast
14 replies
CC#
Created by heftymouse on 10/10/2023 in #help
✅ CoTaskMemFree on a buffer returned by CsWin32
sorry for posting such a half-baked question
14 replies
CC#
Created by heftymouse on 10/10/2023 in #help
✅ CoTaskMemFree on a buffer returned by CsWin32
my code right now looks like this:
using System.Runtime.InteropServices;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.Shell;

PInvoke.SHCreateItemFromParsingName("shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}", null, typeof(IShellItem).GUID, out var e);
IShellItem shellItem = e as IShellItem;
unsafe
{
PWSTR pwstr;
shellItem.GetDisplayName(SIGDN.SIGDN_NORMALDISPLAY, &pwstr);
string thing = new string((char*)pwstr);
Console.WriteLine(thing);
// free pwstr here somehow?
}
using System.Runtime.InteropServices;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.UI.Shell;

PInvoke.SHCreateItemFromParsingName("shell:::{679f85cb-0220-4080-b29b-5540cc05aab6}", null, typeof(IShellItem).GUID, out var e);
IShellItem shellItem = e as IShellItem;
unsafe
{
PWSTR pwstr;
shellItem.GetDisplayName(SIGDN.SIGDN_NORMALDISPLAY, &pwstr);
string thing = new string((char*)pwstr);
Console.WriteLine(thing);
// free pwstr here somehow?
}
Marshal.FreeCoTaskMem dosn't accept the pointer to pwstr directly it seems, and trying to use CoTaskMemFree itself results in an access violation
14 replies