/// <inheritdoc cref="AssocQueryString(uint, ASSOCSTR, PCWSTR, PCWSTR, PWSTR, uint*)"/> public static unsafe HRESULT AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, Span <char> pszOut, ref uint pcchOut) { fixed(char *pszOutLocal = pszOut) { return(AssocQueryString((uint)flags, str, pszAssoc, pszExtra, new PWSTR(pszOutLocal), ref pcchOut)); } }
public static extern HRESULT AssocQueryStringByKeyW( ASSOCF flags, ASSOCSTR str, RegistryKeyHandle hkAssoc, string pszExtra, SafeHandle pszOut, ref uint pcchOut);
public static extern HRESULT AssocQueryStringW( ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, SafeHandle pszOut, ref uint pcchOut);
public static extern int AssocQueryString( [In] ASSOCF flags, [In] ASSOCSTR str, [In] string pszAssoc, [In] string pszExtra, [Out, MarshalAs(UnmanagedType.LPTStr)] StringBuilder pszOut, [In, Out] ref int pcchOut );
public static RegistryKeyHandle AssocQueryKey(ASSOCF flags, ASSOCKEY key, string association, string extraInfo) { HRESULT result = Imports.AssocQueryKeyW(flags, key, association, extraInfo, out RegistryKeyHandle handle); if (result != HRESULT.S_OK) { throw Errors.GetIoExceptionForHResult(result); } return(handle); }
private string GetString(ASSOCSTR astr) { const ASSOCF flags = ASSOCF.ASSOCF_NOTRUNCATE | ASSOCF.ASSOCF_REMAPRUNDLL; var sz = 0U; qassoc.GetString(flags, astr, null, null, ref sz); var sb = new StringBuilder((int)sz, (int)sz); qassoc.GetString(flags, astr, null, sb, ref sz); return(sb.ToString()); }
//[DllImport (Dll.User, SetLastError = true)] //private static extern bool SystemParametersInfo (SPI uiAction, uint uiParam, IntPtr pvParam, SPIF fWinIni); //[DllImport (Dll.User, SetLastError = true)] //private static extern bool SystemParametersInfo (SPI uiAction, uint uiParam, string pvParam, SPIF fWinIni); //[DllImport (Dll.User, SetLastError = true)] //private static extern bool SystemParametersInfo (SPI uiAction, uint uiParam, ref bool pvParam, SPIF fWinIni); //[DllImport (Dll.User, SetLastError = true)] //private static extern bool SystemParametersInfo (SPI uiAction, uint uiParam, ref int pvParam, SPIF fWinIni); /// <summary>Searches for and retrieves a file or protocol association-related string from the registry.</summary> /// <param name="flags">The flags that can be used to control the search. It can be any combination of <see cref="ASSOCF"/> values, except that only one ASSOCF.INIT value can be included.</param> /// <param name="assocStr">The <see cref="ASSOCSTR"/> value that specifies the type of string that is to be returned.</param> /// <param name="doctype">A string that is used to determine the root key. The following four types of strings can be used. File name extension: A file name extension, such as .txt. CLSID: A CLSID GUID in the standard "{GUID}" format. ProgID: An application's ProgID, such as Word.Document.8. Executable name: The name of an application's .exe file. The <see cref="ASSOCF.OPEN_BYEXENAME"/> flag must be set in flags.</param> /// <param name="extra">An optional string with additional information about the location of the string. It is typically set to a Shell verb such as open. Set this parameter to NULL if it is not used.</param> public static string AssocQueryString(ASSOCF flags, ASSOCSTR assocStr, string doctype, string extra = null) { int bufferSize = 0; AssocQueryString(flags, assocStr, doctype, extra, null, ref bufferSize); if (bufferSize == 0) { return(""); } var assoc = new StringBuilder(bufferSize); AssocQueryString(flags, assocStr, doctype, extra, assoc, ref bufferSize); return(assoc.ToString()); }
public static string AssocQueryString(ASSOCF flags, ASSOCSTR @string, string association, string extraInfo) { return(BufferHelper.BufferInvoke((StringBuffer buffer) => { flags |= ASSOCF.NoTruncate; HRESULT result; uint count = buffer.CharCapacity; while ((result = Imports.AssocQueryStringW(flags, @string, association, extraInfo, buffer, ref count)) == HRESULT.E_POINTER) { buffer.EnsureCharCapacity(count); } if (result != HRESULT.S_OK) { throw Errors.GetIoExceptionForHResult(result, association); } // Count includes the null buffer.Length = count - 1; return buffer.ToString(); })); }
public static extern uint AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, [Out] StringBuilder pszOut, [In, Out] ref int pcchOut);
public static extern HRESULT AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, [Out] StringBuilder pszOut, ref uint pcchOut);
public static extern HRESULT AssocQueryKey(ASSOCF flags, ASSOCKEY key, string pszAssoc, string pszExtra, out IntPtr phkeyOut);
public static extern AssocQueryStringResult AssocQueryString(ASSOCF flags, ASSOCSTR str, String pszAssoc, String pszExtra, StringBuilder pszOut, ref UInt32 pcchOut);
public static extern int AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, StringBuilder pszOut, ref uint pcchOut);
public static extern HRESULT AssocQueryKeyW( ASSOCF flags, ASSOCKEY key, string pszAssoc, string pszExtra, out RegistryKeyHandle phkeyOut);