public static Win32Error DsGetRdnW(string fullDN, out string dn, out string key, out string val) { var s = new SafeCoTaskMemString(fullDN, CharSet.Unicode); IntPtr ppDN = s.DangerousGetHandle(), ppKey = IntPtr.Zero, ppVal = IntPtr.Zero; var cDN = (uint)fullDN.Length; var ret = DsGetRdnW(ref ppDN, ref cDN, ref ppKey, out var cKey, ref ppVal, out var cVal); if (ret != 0) { dn = key = val = null; } else { dn = StringHelper.GetString(ppDN, (int)cDN, CharSet.Unicode); key = StringHelper.GetString(ppKey, (int)cKey, CharSet.Unicode); val = StringHelper.GetString(ppVal, (int)cVal, CharSet.Unicode); } return(ret); }
/// <summary>Initializes a new instance of the <see cref="BROWSEINFO"/> struct.</summary> /// <param name="hWnd">A handle to the owner window for the dialog box.</param> /// <param name="rootPidl">A PIDL that specifies the location of the root folder from which to start browsing.</param> /// <param name="title">The string that is displayed above the tree view control in the dialog box.</param> /// <param name="flags">Flags that specify the options for the dialog box.</param> /// <param name="callback">The callback function that the dialog box calls when an event occurs..</param> /// <param name="displayNameBuffer">Buffer that receives the display name of the folder selected by the user.</param> public BROWSEINFO(HWND hWnd, IntPtr rootPidl, string title, BrowseInfoFlag flags, BrowseCallbackProc callback, SafeCoTaskMemString displayNameBuffer) { hwndOwner = hWnd; pidlRoot = rootPidl; pszDisplayName = (IntPtr)displayNameBuffer; lpszTitle = title; ulFlags = flags; lpfn = callback; lParam = IntPtr.Zero; iImage = 0; }
public static extern HRESULT PropVariantToStringAlloc([In] Ole32.PROPVARIANT propVar, [MarshalAs(UnmanagedType.LPWStr)] out SafeCoTaskMemString ppszOut);
public static extern HRESULT PSGetNameFromPropertyKey(ref Ole32.PROPERTYKEY propkey, out SafeCoTaskMemString ppszCanonicalName);
/// <summary>Extracts the string value from this structure by reading process specific memory.</summary> /// <param name="hProc">The process handle of the process from which to read the memory.</param> /// <returns>A <see cref="string"/> that has the value.</returns> public string ToString(HPROCESS hProc) { using var mem = new SafeCoTaskMemString(MaximumLength); return(ReadProcessMemory(hProc, Buffer, mem, mem.Size, out _) ? mem : string.Empty); }
/// <summary>Extracts the string value from this structure by reading process specific memory.</summary> /// <param name="hProc">The process handle of the process from which to read the memory.</param> /// <returns>A <see cref="string"/> that has the value.</returns> public string ToString(HPROCESS hProc) { using var mem = new SafeCoTaskMemString(MaximumLength); return(NtWow64ReadVirtualMemory64(hProc, Buffer, ((IntPtr)mem).ToInt32(), mem.Size, out _).Succeeded ? mem : string.Empty); }