Calling DLL from Ruby

Hi All

Recently I was trying to call an open source tool (STAF) from
Watir(Ruby).

I am supposed to call DDVariableStore.dll

But when the program is being executed, I get the error :-

D:/Program Files/Watir/unittests/11.rb:6:1n ‘initialize’:
GetProcAddress: STAFUtilities or STAFUtilitiesA
from D:/Program Files/Watir/unittests/11.rb:6

The program code is

require ‘Watir’
require ‘Win32API’

class STAF_Watir_Interface

def processRequest(otrd)

oresult = Win32API.new(“DDVariableStore”,“STAFResult”,"","")

ostaf = otrd.getSTAFHelper()

status = ostaf.sendQueueMessage(debuglog, sinfo & “HookScript
processing request…”)

otrd.setStatusCode(-1)
otrd.setStatusInfo("")

message = "I did good on line "& otrd.getLineNumber()
details = “I deserve something special!”

status = ostaf.logPassedMessage(otrd.getFac(), message, details,
oresult)

processRequest = otrd.getStatusCode()
end

engine = “SAFS/Watir”

shutdown = “False”

astaf = Win32API.new (“DDVariableStore”,“STAFUtilities”,"","")
otrd = Win32API.new(“DDVariableStore”,“TestRecordData”,"","")
oresult = Win32API.new(“DDVariableStore”,“STAFResult”,"","")

otrd.setSTAFHelper(ostaf)

status = ostaf.registerNewProcess(engine)

handleid = ostaf.getHandleID()

status = ostaf.sendQueueMessage(debuglog, sinfo & “HookScript
initializing…”)
status = ostaf.resetHookEvents(engine)
status = ostaf.postEvent(engine & “Start”)

while (shutdown == False) do

status = ostaf.sendQueueMessage(debuglog, sinfo & “HookScript Ready”)
status = ostaf.postEvent(engine & “Ready”)
status = ostaf.getNextHookTestEvent(engine)
status = ostaf.sendQueueMessage(debuglog, sinfo & “HookScript
Dispatched”)

 otrd.reinitialize()

 status = ostaf.getTestRecordDataVariant(otrd)

 record = otrd.getInputRecord()

 if record == "SHUTDOWN_HOOK" then

shutdown = “True”
end

if (shutdown == “False”) then
status = processRequest(otrd)
status = ostaf.sendQueueMessage(debuglog, sinfo & "HookScript
Results: "& status)
status = ostaf.sendTestRecordResultsVariant (otrd)
status = ostaf.setHookTestResultsEvents(engine, 2)
status = ostaf.resetEvent(engine & “Running”)
else
status = ostaf.sendQueueMessage(debuglog, sinfo & “HookScript
Shutting Down”)
status = ostaf.postEvent(engine &“Results”)
end
end

status = ostaf.resetHookEvents(engine)
status = ostaf.postEvent(engine &“Shutdown”)
status = ostaf.sendQueueMessage(debuglog, sinfo & “HookScript
Shutdown”)
status = ostaf.unRegisterProcess ()

end

Please correct me if my code is wrong.

Please crosscheck if Win32API was used properly.

The problem starts at this line ---- astaf =
Win32API.new(“DDVariableStore”,“STAFUtilities”,"","")

Bye and Thanx in advance

Meghanath

On 7/18/06, Chintakrindi Meghanath
[email protected] wrote:

Hi All

Recently I was trying to call an open source tool (STAF) from Watir(Ruby).

I am supposed to call DDVariableStore.dll

But when the program is being executed, I get the error :-

D:/Program Files/Watir/unittests/11.rb:6:1n ‘initialize’: GetProcAddress: STAFUtilities or STAFUtilitiesA
from D:/Program Files/Watir/unittests/11.rb:6

That means Win32API couldn’t find a method called “STAFUtilities” in
the DLL “DDVariableStore.DLL”. I guess you should check to see if it’s
really there or if it’s defined in some other DLL.

Regards,
Sean

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs