<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: python+ctypes fails to find my dll in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509128#M39996</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Doesn't help with differing path names.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Aug 2011 17:33:39 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2011-08-23T17:33:39Z</dc:date>
    <item>
      <title>python+ctypes fails to find my dll</title>
      <link>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509125#M39993</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a python script which calls a dll, a la &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001500000013000000.htm"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001500000013000000.htm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It worked fine when the path to the dll was hardcoded:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ctypes.windll.LoadLibrary(u'c:\absolute\path\to\my.dll')&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but now I'd like to distribute the dll to other people, I don't know the absolute path.&amp;nbsp; It will however be in the same folder as the python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But neither of these work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ctypes.windll.LoadLibrary(u'my.dll')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ctypws.windll.my&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;...both return the error "The specified module could not be found".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know how to solve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 14:53:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509125#M39993</guid>
      <dc:creator>CrispinCooper</dc:creator>
      <dc:date>2011-08-23T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: python+ctypes fails to find my dll</title>
      <link>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509126#M39994</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Would this work?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp; 
import sys, os.path
scriptName = sys.argv[0]
pathName = os.path.dirname(scriptName)
dllFile = "mydll.dll"
locatedAt = (pathName + "/" + dllFile).replace("\\","/")
print "script name", scriptName
print "path to script", pathName
print "dll location", locatedAt
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:18:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509126#M39994</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2021-12-11T22:18:28Z</dc:date>
    </item>
    <item>
      <title>Re: python+ctypes fails to find my dll</title>
      <link>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509127#M39995</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;ctypes.windll.LoadLibrary(r'c:\absolute\path\to\my.dll')
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Need that 'r' in front of the string.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:18:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509127#M39995</guid>
      <dc:creator>JasonScheirer</dc:creator>
      <dc:date>2021-12-11T22:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: python+ctypes fails to find my dll</title>
      <link>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509128#M39996</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Jason&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Doesn't help with differing path names.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Aug 2011 17:33:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509128#M39996</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-08-23T17:33:39Z</dc:date>
    </item>
    <item>
      <title>Re: python+ctypes fails to find my dll</title>
      <link>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509129#M39997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Would this work?&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes.&amp;nbsp; Excellent suggestion, thank you. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
dirname = os.path.dirname(sys.argv[0])
dll = ctypes.windll.LoadLibrary(dirname+"\\my.dll")
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:18:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-ctypes-fails-to-find-my-dll/m-p/509129#M39997</guid>
      <dc:creator>CrispinCooper</dc:creator>
      <dc:date>2021-12-11T22:18:35Z</dc:date>
    </item>
  </channel>
</rss>

