Jump to content

how to call ocx file(COM) ?


tts
 Share

Recommended Posts

I have a OCX file (stock API)

But don't know how to use this

Tried: ObjCreate ("PFFutOrdAP.DPFFutOrdAP")

But error (not Object)

So come here to ask, how do I correctly use it?

Also attach a file, VB code, Exported Functions List

Hope someone can help

thanks~

file link:

http://www.box.net/shared/aklmf5ck8a

http://www.badongo.com/file/24225924

Edited by tts
Link to comment
Share on other sites

Did you register the library on the machine first?

RunWait('RegSvr32.exe "test.ocx"',@ScriptDir)

Replace test.ocx with the name of your file.

Edited by FuryCell
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

tts, if you can upload your file somewhere else, where I don't have to wait to download it and see annoying adds, maybe I can help you.

Try box.net or something else.

M.I.

Link to comment
Share on other sites

tts, if you can upload your file somewhere else, where I don't have to wait to download it and see annoying adds, maybe I can help you.

Try box.net or something else.

M.I.

thanks,new link is: http://www.box.net/shared/aklmf5ck8a

$oPFF = ObjCreate("PFFUTORDAP.PFFutOrdAPCtrl.1")

try this

thank you,can use!!

but i dont know why use "PFFutOrdAPCtrl.1"

can you talk about the principle of?

and..

this is VBA code:

If PFFutOrdAP1 Is Nothing Then
        Set PFFutOrdAP1 = New PFFutOrdAPLib.PFFutOrdAP
    End If

    Dim CSetting As Class1
    Dim OrderServerIP As String, OrderServerPort As String, ReportServerPort As Integer
    Dim MatchServerIP As String, MatchServerPort As String
    Dim OrderServerUser As String, OrderServerPwd As String
    Dim MatchServerUser As String, MatchServerPwd As String
    Dim GroupID As String
    
    Set CSetting = New Class1
    CSetting.InitByPath Application.DefaultFilePath & "\PS_FutureTrade.ini", csModeINI
    
    OrderServerIP = CSetting.GetSettingStr("Setting", "OrderServerIP", "127.0.0.1")
    OrderServerPort = CSetting.GetSettingStr("Setting", "OrderServerPort", "9801")
    ReportServerPort = CSetting.GetSettingStr("Setting", "ReportServerPort", "9802")
    
    OrderServerUser = CSetting.GetSettingStr("Setting", "OrderServerUser", "")
    OrderServerPwd = CSetting.GetSettingStr("Setting", "OrderServerPwd", "")
    
    GroupID = CSetting.GetSettingStr("Setting", "Group", "")
    Set CSetting = Nothing
    
    Call PFFutOrdAP1.SetFutOrdConnection(OrderServerUser, OrderServerPwd, GroupID, OrderServerIP, OrderServerPort)
    Call PFFutOrdAP1.SetFutRptConnection(OrderServerUser, OrderServerPwd, GroupID, OrderServerIP, ReportServerPort, 0)

but i try

$Obj = ObjCreate("PFFUTORDAP.PFFutOrdAPCtrl.1")

$aabbd=$Obj.SetFutOrdConnection("str",$user,"str",$pwd,"str",$group,"str",$ip,"str",$port)
;or
;$aabbd=$Obj.SetFutOrdConnection($user,$pwd,$group,$ip,$port)

both error...

Where is wrong with it??

Link to comment
Share on other sites

; create the object
$oPFFutOrdAP1 = ObjCreate("PFFUTORDAP.PFFutOrdAPCtrl.1")

; the objects events
$iDPFFutOrdAPEvent = ObjEvent($oPFFutOrdAP1,"DPFFutOrdEvent_", "_DPFFutOrdAPEvents")

$oPFFutOrdAP1.DoLogout()

$oPFFutOrdAP1.SetFutOrdConnection($user,$pass,$group,$ip,$port)

$oPFFutOrdAP1.AskRecover($askseq)

$oPFFutOrdAP1.SetFutRptConnection($user,$pass,$group,$ip,$port,$lastseq)

; some of the events i found 
Func DPFFutOrdEvent_DragDrop($source,$x,$y)
EndFunc

Func DPFFutOrdEvent_OnOrdError($ClOrdID, $ErrorCell)
EndFunc

Func DPFFutOrdEvent_OnStatusChange($Statusr,$Result)
EndFunc

just so you know i haven't tried this out i have no clue what the ocx is for

you just have to figure the rest out and see if it works, im new to autoit myself

i just read the help file!

Link to comment
Share on other sites

but i dont know why use "PFFutOrdAPCtrl.1"

can you talk about the principle of?

I'm not that familiar with COM, but assume, ".1" equals the first and perhaps only instance of the COM object that you can instantiate? Some COM components/objects are like that. Might also be based on how the COM was developed (e.g. C++ vs VB, etc.).

Reading a COM programming book may shed some light on that.

Link to comment
Share on other sites

but i try

$Obj = ObjCreate("PFFUTORDAP.PFFutOrdAPCtrl.1")

$aabbd=$Obj.SetFutOrdConnection("str",$user,"str",$pwd,"str",$group,"str",$ip,"str",$port)
;or
;$aabbd=$Obj.SetFutOrdConnection($user,$pwd,$group,$ip,$port)

both error...

Where is wrong with it??

What error message do you get exactly? That can help determine the problem.
Link to comment
Share on other sites

A comment & suggestion:

Why are you using AutoIt to access the OCX COM object? Are you using AutoIt only to access the OCX COM object or are you integrating it with other AutoIt features like GUI automation/manipulation, or other AutoIt third party UDF libraries, etc.?

Do you need to compile the AutoIt code to a binary executable? Can you use AutoItX COM interface to AutoIt instead? AutoItX requires registering the AutoItX DLL on systems that don't already have AutoIt installed.

Because if possible, I suggest you consider working with your OCX COM object directly in VBScript and integrate with AutoIt in VBScript via AutoItX COM interface if you need AutoIt features. VBScript is much more closer to VB or VBA, therefore adapting or porting the VB/VBA code you have into VBScript will be less painful and easier.

VBScript also has the benefit that it does not need to be compiled. You can run it with Windows Scripting Host: on the command line, via "cscript scriptname.vbs [optional arguments to script file]", or by double-clicking script file on Windows desktop to run under wscript (no command line arguments).

And you don't need to install VBScript. It is available on all Windows systems.

Link to comment
Share on other sites

thanks everyone very much

but try

$oPFFutOrdAP1 = ObjCreate("PFFUTORDAP.PFFutOrdAPCtrl.1")
$oPFFutOrdAP1.SetFutOrdConnection($user,$pass,$group,$ip,$port)

still error,this is the error message

post-60067-12859211298777_thumb.jpg

A comment & suggestion:

Why are you using AutoIt to access the OCX COM object? Are you using AutoIt only to access the OCX COM object or are you integrating it with other AutoIt features like GUI automation/manipulation, or other AutoIt third party UDF libraries, etc.?

Do you need to compile the AutoIt code to a binary executable? Can you use AutoItX COM interface to AutoIt instead? AutoItX requires registering the AutoItX DLL on systems that don't already have AutoIt installed.

Because if possible, I suggest you consider working with your OCX COM object directly in VBScript and integrate with AutoIt in VBScript via AutoItX COM interface if you need AutoIt features. VBScript is much more closer to VB or VBA, therefore adapting or porting the VB/VBA code you have into VBScript will be less painful and easier.

VBScript also has the benefit that it does not need to be compiled. You can run it with Windows Scripting Host: on the command line, via "cscript scriptname.vbs [optional arguments to script file]", or by double-clicking script file on Windows desktop to run under wscript (no command line arguments).

And you don't need to install VBScript. It is available on all Windows systems.

I understand more easily with VB

But I am more familiar autoit, I also believe autoit have infinite possibilities

Link to comment
Share on other sites

Hmm...that's a cryptic/generic error message. But it probably tells you that the syntax for the call is incorrect, or perhaps not callable from AutoIt (that can happen for certain cases where the COM interface was designed more for use by a certain language like VB or C++). If incorrect syntax, the problem is finding out what is the correct syntax. Since most COM software does not include support & samples for use with AutoIt, you are on your own using trial and error to get it to work.

As for your preference for AutoIt, IMHO, with exception to doing all programming in AutoIt as if it was one's favorite language, if all one uses AutoIt for is basic (non-GUI) programming, such as accessing COM objects, or perhaps to use its GUI automation functions instead, then there is greater possibilities that can be achieved through VBScript:

AutoItX COM interface + VBscript = same use of AutoIt GUI automation functions, but now with the power of VBScript features, and you can integrate or interact with other COM objects as well. Also potentially easier learning/knowledge transfer. Using this method, one just needs to know VBScript and the AutoIt GUI automation functions/API. If going the AutoIt only route, one must learn the AutoIt language, which is a variant of PHP & VBScript.

Working with COM using VBScript = easy to work with COM objects compared to AutoIt. Minimal adaptation/porting from VB/VBA code. And the COM application may include technical support for and code samples for VBScript. No need for trial & error figuring out how to call the COM functions.

Link to comment
Share on other sites

There is no guarantee that this will work in AutoIt... please read the Obj/COM reference section in the helpfile for important restrictions.

First thing I would ask, however is whether you are passing strings (rather than ints) into all of the parameters. Please try using quoted literals as your parameters instead of variables to verify this.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...