title: Declaring third party DLL dynamically in VB.NET
body: <p>I'm facing a problem importing a DLL on different environments.
  I have to check Windows platform and import the third-party DLL that will be placed in <code>C:\Program Files\</code> (for <code>32-bit</code>) or <code>C:Program Files (x86)\</code> (for <code>64-bit</code>).</p>
  
  <p>Before the code was written like this:</p>
  
  <pre><code>Declare Function RDRCConnect Lib "c:\program files\TP-DLL\RDRCAP32.DLL" (ByVal lpszServerName As String, ByVal lNetConnType As Integer, ByVal lpszParam1 As String, ByVal lpszParam2 As String, ByVal lpszParam3 As String, ByRef lNetConn As Integer, ByRef lNetErr As Integer) As Integer  
  Declare Function RDRCDisconnect Lib "c:\program files\TP-DLL\RDRCAP32.DLL" (ByVal lNetConn As Integer, ByRef lNetErr As Integer) As Integer
  </code></pre>
  
  <p>...and I changed to use attributes:</p>
  
  <pre><code>Private Const CheminDLL As String = "C:\Program Files\TP-DLL\RDRCAP32.DLL"
  
  &lt;System.Runtime.InteropServices.DllImport(CheminDLL)&gt;
  Private Shared Function RDRCConnect(ByVal lpszServerName As String, ByVal lNetConnType As Integer, ByVal lpszParam1 As String, ByVal lpszParam2 As String, ByVal lpszParam3 As String, ByRef lNetConn As Integer, ByRef lNetErr As Integer) As Integer
  End Function
  </code></pre>
  
  <p>How can I change the DLL path dinamically in this scenario, once the DLLImport expects a Constant as parameter?</p>