示例#1
0
 /// <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));
     }
 }
示例#2
0
 public static extern HRESULT AssocQueryStringByKeyW(
     ASSOCF flags,
     ASSOCSTR str,
     RegistryKeyHandle hkAssoc,
     string pszExtra,
     SafeHandle pszOut,
     ref uint pcchOut);
示例#3
0
 public static extern HRESULT AssocQueryStringW(
     ASSOCF flags,
     ASSOCSTR str,
     string pszAssoc,
     string pszExtra,
     SafeHandle pszOut,
     ref uint pcchOut);
示例#4
0
 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
     );
示例#5
0
        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);
        }
示例#6
0
        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());
        }
示例#7
0
        //[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());
        }
示例#8
0
        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();
            }));
        }
示例#9
0
 public static extern uint AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, [Out] StringBuilder pszOut, [In, Out] ref int pcchOut);
示例#10
0
 public static extern HRESULT AssocQueryString(ASSOCF flags, ASSOCSTR str,
                                               string pszAssoc, string pszExtra, [Out] StringBuilder pszOut,
                                               ref uint pcchOut);
示例#11
0
 public static extern HRESULT AssocQueryKey(ASSOCF flags, ASSOCKEY key, string pszAssoc, string pszExtra, out IntPtr phkeyOut);
示例#12
0
 public static extern AssocQueryStringResult AssocQueryString(ASSOCF flags, ASSOCSTR str, String pszAssoc, String pszExtra, StringBuilder pszOut, ref UInt32 pcchOut);
示例#13
0
 public static extern int AssocQueryString(ASSOCF flags, ASSOCSTR str, string pszAssoc, string pszExtra, StringBuilder pszOut, ref uint pcchOut);
示例#14
0
 public static extern HRESULT AssocQueryKeyW(
     ASSOCF flags,
     ASSOCKEY key,
     string pszAssoc,
     string pszExtra,
     out RegistryKeyHandle phkeyOut);