# C1.Util.Win.Win32.AssocQueryString

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_Win_Win32_AssocQueryString_" data-uid="C1.Util.Win.Win32.AssocQueryString*">AssocQueryString Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_Win_Win32_AssocQueryString_" data-uid="C1.Util.Win.Win32.AssocQueryString*"></a>
<h4 id="C1_Util_Win_Win32_AssocQueryString_System_Int32_System_Int32_System_String_System_String_System_Text_StringBuilder_System_UInt32__" data-uid="C1.Util.Win.Win32.AssocQueryString(System.Int32,System.Int32,System.String,System.String,System.Text.StringBuilder,System.UInt32@)">AssocQueryString(int, int, string, string, StringBuilder, ref uint)</h4>
<div class="markdown level1 summary"><p>Gets file-association string from the registry.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static extern uint AssocQueryString(int flags, int str, string pszAssoc, string pszExtra, StringBuilder pszOut, ref uint pcchOut)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function AssocQueryString(flags As Integer, str As Integer, pszAssoc As String, pszExtra As String, pszOut As StringBuilder, ByRef pcchOut As UInteger) As UInteger</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">flags</span></td>
      <td><p>Use <a class="xref" href="C1.Util.Win.Win32.ASSOCF.html">Win32.ASSOCF</a> constants.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">str</span></td>
      <td><p>Use <a class="xref" href="C1.Util.Win.Win32.ASSOCSTR.html">Win32.ASSOCSTR</a> constants.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">pszAssoc</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">pszExtra</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.text.stringbuilder">StringBuilder</a></td>
      <td><span class="parametername">pszOut</span></td>
      <td></td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a></td>
      <td><span class="parametername">pcchOut</span></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a></td>
      <td><p>An <a class="xref" href="C1.Util.Win.Win32.OLE.html">Win32.OLE</a> success/error code.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_Win_Win32_AssocQueryString_System_Int32_System_Int32_System_String_System_String_System_Text_StringBuilder_System_UInt32___remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>To get associated exe's length/exe:</p>
<pre><code class="lang-csharp">uint assocLen = 0;
AssocQueryString(ASSOCF.ASSOCF_INIT_DEFAULTTOSTAR,ASSOCSTR.ASSOCSTR_EXECUTABLE,Path.GetExtension(OutputFileName),"open",null,ref assocLen);</code></pre>
<p>For existing files, another option is FindExecutable.</p>
</div>
</div>
