PDA

View Full Version : Calling ActiveX dll's from AMS



clueless
06-13-2008, 01:17 AM
Would it be possible to create a C++ wrapper for an activeX dll so that it could be used in AMS?

Dermot
06-13-2008, 11:02 AM
Why would you do that when you can just use LuaCOM to work with the ActiveX dll.

clueless
06-14-2008, 11:33 AM
Ive never really looked into using LUA, ive been avoiding learning any more high level languages as I've just started studying vc++.If its just a case of adding a few lines of code to an AMS project then it might be worth looking into. Do you have any links to some sample code?

Ive been toying with the idea of making a tool that could take an ordinary ActiveX.dll and then with some user input,automaticly build the code for a C++ wrapper so the functions would be accessable from any language. I know something similar has been done for languages like PowerBasic http://winch.pinkbile.com/wiki/index.php/Main/Dlltool

I was supprised to learn the VisualBasic6 CAN make standard windows Dll's after all. It just takes a bit of messing about with the way it compiles. http://www.vb-helper.com/howto_make_standard_dll.html
http://www.windowsdevcenter.com/pub/a/windows/2005/04/26/create_dll.html

clueless
06-18-2008, 02:21 PM
I was supprised to learn the VisualBasic6 CAN make standard windows Dll's after all. It just takes a bit of messing about with the way it compiles. http://www.vb-helper.com/howto_make_standard_dll.html
http://www.windowsdevcenter.com/pub/...reate_dll.html

Has anyone else tried this at all? I had a go last night but couldnt make the dll work with AMS. :rolleyes
Theres a few software addons for visual basic6 that claim to be able to expose the functions to create a standard windows dll as well. It would be great to be able to do this without having to go into VC++ :D

clueless
06-20-2008, 03:59 PM
..lol. Not getting a lot of intrest in this subject. What im trying to do is convert my dynamic masking tool for AMS into a dll (Ill still be giving it away free). Im slowly learning c++ so eventually ill be able to do this the correct way. Ive made it into an activeX dll without to much stress.

What i need to know is ..could this VB6 solution work with AMS... in theory?

Will this realy produce a real dll or is it some dodgy workaround thats never going to run correctly if called from AMS?

Dermot
06-20-2008, 06:16 PM
Has anyone else tried this at all? I had a go last night but couldnt make the dll work with AMS. :rolleyes
Theres a few software addons for visual basic6 that claim to be able to expose the functions to create a standard windows dll as well. It would be great to be able to do this without having to go into VC++ :D
Yes I have tested this and it worked perfectly. The attached apz has a simple dll and an activex dll I created using that technic. I no longer have the VB source though. It is definetly an easy way to create dlls.

clueless
06-20-2008, 06:19 PM
:wow... Thanks. Looks like im going to be busy all weekend :lol

clueless
06-20-2008, 09:18 PM
I found a small patch for VB6 that takes care of the renaming of the linker etc..

It comes with sample code to :)

Dermot
06-20-2008, 09:35 PM
I found a small patch for VB6 that takes care of the renaming of the linker etc..

It comes with sample code to :)
Nice! That makes it much easier. :yes:yes

clueless
06-22-2008, 12:04 AM
I finaly managed to do this to :D

Ill see if i can get my dynamic masking tool done next .

clueless
06-23-2008, 09:29 AM
Hmm.. this is a bit more complex than i had anticipated.

The code for the dll has to but put into a .bas module, if i use forms within the dll code the dll just crashes. But the image manipulation functions Ive made all require a bitmap to be displayed in a standard picture object before i can point a safearray to its structure to gain a valid reference to be able to edit its pixels quickly.

I know bitmaps can be referenced without first displaying them because Ive done it a few times by mistake while working out how safe arrays worked.

I might just press on and work out how to do this the correct way in MFC .lol

clueless
07-23-2008, 05:33 AM
Ive finnaly discovered how this can be done;


VB6 programs at runtime make significant use of COM interfaces, even if the source
code does not use COM objects explicitly. Some critical runtime support mechanisms,
including error handling, are COM-based (eg. the Err object). VB6 applications
(EXE’s) automatically initialise their COM environment when executed, but VB6 DLL’s
only initialise COM when the client application uses the DLL via a COM interface, not
as an API (a shared library).
If a client application calls a VB6 DLL function directly, the DLL’s runtime state has no
COM capability, and so the DLL will abort if it makes any sort of COM object
reference. This has fatal consequences for the entire client process.

But it does seem that there is a way to handle the COM instantiation correctly so you can use VB normally Solution (http://www.xtremevbtalk.com/showthread.php?t=282796) :cool .

RizlaUK
07-23-2008, 06:45 AM
altho this is very useful info, it takes away the power and flexabilty to make a static dll for AMS as its single threaded dll calls, i like working with ocx files now more than dll files

if we had some more dll actions then yeah, it would be great

DLL.Open("myfile.dll")
DLL.CallFunction("Function",arg0,arg1,arg2)
DLL.Close()

then at least we could open the dll in memory and work with it that way

clueless
07-23-2008, 07:53 AM
altho this is very useful info, it takes away the power and flexabilty to make a static dll for AMS as its single threaded dll calls
Could you elaborate?

RizlaUK
08-03-2008, 08:46 PM
AMS calls a dll and waits for its return, the app waits, nothing happens till the dll has finished its job

with an activex dll you can call the function and the app can carry on working and you can recive events from the activex while its working before the function returns

i only see this method as being any good for making a dll for pure basic or any other dev tool that can *open* a dll and work with it that way

the key is communication, something that lacks with AMS dll calls and for a dynamic masking tool i would want some communication between the app and the dll

but, everyone has there own view

clueless
08-03-2008, 11:48 PM
Ahh, I didn't know that.

I cant see how this would affect the DMT as this is how it was designed to work in the first place. There's no need for any kind of multi threading because you only need to work one window at a time. I spent a long time working out how to combine the masks very quickly so this could be done on the fly eg. Call the program..when its finished load the new mask.

RizlaUK
08-04-2008, 07:15 AM
yeah, i mean dont redesign your plugin, i just ment for future reference it would be worth bearing in mind, like you say, you took a long time getting it all in one call

also the are situations where you do not need to have the dll open, like most single call dll's that iv made for AMS, but the power of ActiveX is endless, every day i find some new trick and make something happen in AMS that wouldent usaly be possable.

clueless
08-04-2008, 08:40 AM
To be honest the whole process is quite tricky and there doesn't seem to be many people about who know much about it so help is almost non-existent.
Ive made a dll with a whole bunch of maths functions (that are not available in AMS) using this method but I don't think I'm going to go any further than that with it.