title: Can I call this 32bit dll in 64bit python using interprocess comunication?
body: <p>I need to call a 32 bit dll from 64 bit python and I am having trouble finding a good example using interprocess communication. I don't need to pass or return anything complicated. The dll is for corpscon which converts coordinates to different systems. Is there a best way to wrap the 32 bit dll. I looked at MSLoadlib but I am having trouble understanding how I would load my dll with MSLoadlib.</p>
  
  <p>Here is the code,</p>
  
  <pre><code>from ctypes import *
  import os
  
  def conCoords(sysOutNum,outdatyear,outzonecode,inX,inY,inZ):
      corpslib = windll.LoadLibrary("C:\Program Files\CORPSCON6\corpscon_v6.dll")
      test00 = corpslib.corpscon_default_config()
      SetNadconPath = corpslib.SetNadconPath
      SetVertconPath = corpslib.SetVertconPath
      SetGeoidPath = corpslib.SetGeoidPath
      SetInSystem = corpslib.SetInSystem
      SetOutSystem = corpslib.SetOutSystem
      SetInDatum = corpslib.SetInDatum
      SetOutDatum = corpslib.SetOutDatum
      SetInZone = corpslib.SetInZone
      SetOutZone = corpslib.SetOutZone
      SetInUnits = corpslib.SetInUnits
      SetOutUnits = corpslib.SetOutUnits
      SetInVDatum = corpslib.SetInVDatum
      SetOutVDatum = corpslib.SetOutVDatum
      SetInVUnits = corpslib.SetInVUnits
      SetOutVUnits = corpslib.SetOutVUnits
      SetGeoidCodeBase = corpslib.SetGeoidCodeBase
      SetXIn = corpslib.SetXIn
      SetYIn = corpslib.SetYIn
      SetZIn = corpslib.SetZIn
      GetXOut = corpslib.GetXOut
      GetYOut = corpslib.GetYOut
      GetZOut = corpslib.GetZOut
  
      import ctypes
  
      SetNadconPath.argtypes = [ctypes.c_char_p]
      SetNadconPath.retval = [ctypes.c_int]
      SetVertconPath.argtypes = [ctypes.c_char_p]
      SetVertconPath.retval = [ctypes.c_int]
      SetGeoidPath.argtypes = [ctypes.c_char_p]
      SetGeoidPath.retval = [ctypes.c_int]
      SetInSystem.argtypes = [ctypes.c_int]  
      SetInSystem.retval = [ctypes.c_int]  
      SetInDatum.argtypes = [ctypes.c_int]  
      SetInDatum.retval = [ctypes.c_int]  
      SetOutDatum.argtypes = [ctypes.c_int]
      SetOutDatum.retval = [ctypes.c_int]
      SetOutSystem.argtypes = [ctypes.c_int]  
      SetOutSystem.retval = [ctypes.c_int]  
      SetInZone.argtypes = [ctypes.c_int]      
      SetInZone .retval = [ctypes.c_int]  
      SetOutZone.argtypes = [ctypes.c_int]    
      SetOutZone .retval = [ctypes.c_int] 
      SetInUnits.argtypes = [ctypes.c_int]  
      SetInUnits .retval = [ctypes.c_int]   
      SetInVDatum.argtypes = [ctypes.c_int]     
      SetInVDatum .retval = [ctypes.c_int]     
      SetOutVDatum.argtypes = [ctypes.c_int]    
      SetOutVDatum .retval =[ctypes.c_int]    
      SetInVUnits.argtypes = [ctypes.c_int]   
      SetInVUnits .retval = [ctypes.c_int]   
      SetOutVUnits.argtypes = [ctypes.c_int]    
      SetOutVUnits .retval = [ctypes.c_int]  
      SetGeoidCodeBase.argtypes = [ctypes.c_int]    
      SetGeoidCodeBase.retval = [ctypes.c_int]  
      SetXIn.argtypes = [ctypes.c_double]  
      SetXIn.retval = [ctypes.c_int]  
      SetYIn.argtypes = [ctypes.c_double]  
      SetYIn.retval = [ctypes.c_int]  
      SetZIn.argtypes = [ctypes.c_double]  
      SetZIn.retval = [ctypes.c_int]  
      GetXOut.retval =[ctypes.c_double]  
      GetYOut.retval =[ctypes.c_double]  
      GetZOut.retval = [ctypes.c_double]  
  
      test1 = SetNadconPath(r"C:\Program Files\CORPSCON6\Nadcon")
      test2 = SetVertconPath(r"C:\Program Files\CORPSCON6\Vertcon")
      test3 = SetGeoidPath(r"C:\Program Files\CORPSCON6\Geoid")
  
      ###################################
      ##
      ## Set Geographic or Stateplane
      ##
      ##################################
      sysInNum = 2 
      insys = SetInSystem(sysInNum)
      outsys = SetOutSystem(sysOutNum)
  
      ###################################
      ##
      ## Set Datum 83 or 27
      ##
      ##################################
      datumInYear = 1983
      indat = SetInDatum(datumInYear)
      datumOutYear = outdatyear
      outdat = SetOutDatum(datumOutYear)
  
      ###################################
      ##
      ## Set Zone ie 4202
      ##
      ##################################
  
      incode = 4202
      inzone = SetInZone(incode)
  
      outcode = outzonecode
      outzone = SetOutZone(outcode)
  
      ###################################
      ##
      ## Set Units
      ##
      ##################################
  
      units = 1
  
      outunits = SetOutUnits(units)
      inunits = SetInUnits(units)
  
  
      ###################################
      ##
      ## Set V Datum
      ##
      ##################################
  
      invdatum = SetInVDatum(1988)
      outvdatum = SetOutVDatum(1988)
  
  
      ###################################
      ##
      ## Set V Units
      ##
      ##################################
  
      invunits = SetInVUnits(1)
      outvunits = SetOutVUnits(1)
  
      geoidbase = SetGeoidCodeBase(2003)
  
      intcorpse = corpslib.corpscon_initialize_convert()
  
      #inX = 2790955
      #inY = 503380 
      #inZ = 2800.00
  
      xin = c_double(inX)
      yin = c_double(inY)
      zin = c_double(inZ)
  
      xout = c_double()
      yout = c_double()
      zout = c_double()
  
      SetXIn(xin)
      SetYIn(yin)
      SetZIn(zin)
  
      corpslib.corpscon_convert()
  
      corpslib.GetXOut.restype = c_double
      corpslib.GetYOut.restype = c_double
      corpslib.GetZOut.restype = c_double
  
      pntX = corpslib.GetXOut()
      pntY = corpslib.GetYOut()
      pntZ =  corpslib.GetZOut()
  
  
  
      return pntX,pntY,pntZ
  
  x,y,z = conCoords(2,1983,4202,2790955,503380,2800.00)
  print(x,y,z)
  </code></pre>
  
  <p>The corpscon dll can be found here.</p>
  
  <p><a href="http://cdm16021.contentdm.oclc.org/utils/getfile/collection/p16021coll1/id/220/filename/221.dll" rel="nofollow noreferrer">Corpscon.dll</a></p>