From: "Omran N." Date: 2011-11-23T20:41:28+09:00 Subject: Newbie: Calling dll functions from Ruby for a customer dll Hello, I have searched to forum previosly but have found little in the way on concrete examples. This might just be my inexperience hence the 'Newbie' in the title. I want to introduce Ruby into my Python addicted office. One way I would like to acheive that is by converting some of our useful scripts to Ruby. The script essentially calls a dll which was created internally long ago by our engineers. It controlls a peice of hardware and also quesries it based on an API which we provide. If I can quickly convert it to Ruby it would help me to prove its worth. Please have patience with me if I am being a bit thick here. Here is the initial crux of the code in Python which I want to Rubify: ------------------------------------------------------------------------- import os import sys import re import time from ctypes import * from datetime import datetime from threading import Thread #Open a file for logging AutomationLogsPath = os.getcwd() #Open a file for logging currentTime = time.strftime('%d.%m.%y_%H_%M_%S') filename = AutomationLogsPath + "\\WCDMA_DATACALL" + currentTime + ".log" fp = open(filename,"a") #Change the current working directory to the one containing dlls. os.chdir("C:\\Program Files\\Aeroflex\\7100\\Remote Control\\Bin") try: h_rrcApi = windll.LoadLibrary('afRrcApiInterfaceDll.Dll') h_wcdmaApi = windll.LoadLibrary('afWCDMAApiInterfaceDll.dll') h_ControlLib = windll.LoadLibrary('afApplicationControlDll.Dll') except WindowsError: time = datetime.now().isoformat() fp.write(time + "\tLoadLibrary failed to find the dll!\n") print "LoadLibrary failed to find the dll!\n" fp.close() exit(-1) ------------------------------------------------------------------------- Thank you for reading this. Imran -- Posted via http://www.ruby-forum.com/.