PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Need ActiveX / COM info

Hi,

I have almost finished implementing the COM functions into PPL but I have a problem. I see a bunch of COM objects in my registry but I don't know what methods (names) they have in them. I can load them but I need to be able to Invoke a method. I would like to test with a an easy object. I have seen the "GridCtrl.GridCtrl.1" and would like to Invoke one of it's method.

Or maybe someone has a com object that has all the documentation with it?
PointOfLight · 15 Aug 2004, 03:47 UTC
One I've been playing around with is ASpriteCE (www.spritehand.com). There is also, of course, the ADOCE object, which you can get from Microsoft. Don't know how good the documentation is for that, but I could probably help you out with a sample on that one if you need it.
Hi PointOfLight,

Thanx for replying. The problem I am having is figuring out how to access an interface with and then invoke a method or get/set a property.

Do you know if an interface inside a COM component has a CLSID too just like a COM component? If so, maybe I can find a way to get the interface's CLSID by using it's name (like: IID_WHATEVER).
PointOfLight · 15 Aug 2004, 04:22 UTC
I'm not sure if a COM interface has a CLSID or if it's just accessed by the inteface name. The main reference I can offer is how NSBasic accesses COM object. It has two interfaces: CreateObject and AddObject. Here is a string from a call to each object type: "adoce.connection.3.1" and "AspriteCE.Game". I hope this helps some (I have to confess I'm more of an end user type programmer than an internals type guy).
Hi,

I have found ITypeInfo that allow me to get all interfaces, constants etc... defined within a COM component. This way I can probably implement COM in PPL this way:

Code:
js$ = CreateObject("JScript");
cc$ = QueryInterface("ICodeCompiler");
ShowMessage(Invoke(cc$, "CompilerName"));
DeleteObject(cc$, js$);


or

Code:
ado$ = CreateObject("adoce.connection.3.1");
con$ = QueryInterface("Connection"); // Not sure about this one
Invoke(con$, "Open", "Provider='SQLOLEDB';Data Source='MySqlServer'; Initial Catalog='Northwind';Integrated Security='SSPI';"
Invoke(con$, "Close");
DeleteObject(con$, ado$);


I am just not sure about the names in the createobject.
PointOfLight · 15 Aug 2004, 14:19 UTC
I'm looking forward to this interface. I'll definitely be testing this stuff for you :D
I finally got it to work but I am still confused how to access an interface inside a component. I hope someone can enlighten me. It is not finished yet but I am getting there slowly.

Here is a little code that I used to test.

Code:
com$ = CreateObject("ADOCE.Connection.3.1");
ShowMessage(GetProperty(com$, "Version"));
deleteobject(com$);

com$ = CreateObject("CEComDlg.CommonDialog.1");
ShowMessage(com$);
SetProperty(com$, "InitDir", "\\My Documents\\");
ShowMessage(GetProperty(com$, "InitDir"));
ShowMessage(Invoke(com$, "ShowFont"));
deleteobject (com$);


This piece of code make no sense at all but it show how PPL will implement COM.
A quick update...

This piece of code works like a charm now.

Code:
com$ = CreateObject("ADOCE.RecordSet.3.1");
Invoke(com$, "Open", "create database '\\ado.cdb'");
Invoke(com$, "Open", "create table t1 (c1 integer, c2 varchar(200))", "\\ado.cdb");
Invoke(com$, "Close");
deleteobject(com$);


I have to do further tests and to finish the implementation of all variable types.
Hello All,

I have just returned from my 10-day break. Managed to download the 0.7b release of PPL while I was away. Found a little time to run some basic tests and continue with my GPS programming exercise. All the "fixes" appear to work fine and release 0.7b appears is working well.

Kornalius ... I thought you were having a break ... it certainly wouldn't appear so from the work you have been doing ... looks great and will also be interested in testing some of the ADOCE stuff.

cheers
I was able to implement an #IMPORT directive that loads a type library table and get enumerations and dispatchs guid's. I am then able to create defines with these values.

But the problem I am having is... When I try to CreateObject (CoCreateInstance() in C) using the GUID gotten from the type library it gives me the following error:

"Class not registered".

Code:
#IMPORT "\\windows\\adoce31.dll"

com$ = CreateObject(ADOCE);
i$ = QueryInterface(com$, IID_RecordSet);
ShowMessage(com$+","+i$);
deleteobject(com$);


The following works:

Code:
com$ = CreateObject("ADOCE.RecordSet.3.1");
Invoke(com$, "Open", "create database '\\ado.cdb'");
if (not IsNull(ComError%))
ShowMessage(ComError%);
end;


Does anybody know why adoce31.dll is not registered, while ADOCE.RecordSet.3.1. ProgID is defined in the registry?
PointOfLight · 17 Aug 2004, 19:53 UTC
Again, I'm no low level expert, and this may not really even help answer your question, but even in languages like ASP where you'd use createobject to instantiate an ADO object, you always use the object you want to create, and not the base class. In other words, you'd do an ADODB.Recordset or ADODB.Connection in the CreateObject function, not ADODB by itself. Apparently Microsoft just carried this through to the PPC world.
Then in a case like JSCRIPT, how is it possible to access the object and it's interfaces? I am using JSCRIPT as an example it could be anything else.

Code:
com$ = CreateInstance("JSCRIPT.GlobalObj");


I don't think this will work because it's not part of the registry names. It thought this would do it:

Code:
#import "\\windows\\JSCRIPT.DLL"

com$ = CreateInstance (JSCRIPT);
i$ = QueryInterface(com$, IDD_GlobalObj);


or maybe:

Code:
com$ = CreateInstance(IDD_GlobalObj);


I am very confused about this whole thing, there is not a whole lot of reference out there and it's really working like I think it is suppose to.
PointOfLight · 17 Aug 2004, 21:25 UTC
Is jscript.dll an ActiveX control or just a DLL? When I try to find information concerning jscript.dll and using it in eVB, it shows instantiating it with the command LoadLibrary, which would imply to me that it's not an ActiveX control. I believe all ActiveX controls should have one or more classes that can be created, but will never have a base object that can be created. Of course, it would help if someone more knowledgable in the inner workings of ActiveX would jump into this discussion :)
I think I will leave it this way for now and see what the beta testers come up with. I will then get solid samples and I will see what can be done. So far, the COM functions work very well.

#IMPORT "activex.dll"
CreateObject("clsid or progid")
Invoke(objecthandle$, "method name", [parameters...])
GetProperty(objecthandle$, "property name")
SetProperty(objecthandle$, "property name", value)
T(Value, VariantType)
CreateSafeArray()
SafeArrayDestroy()

I have support for all types of VARIANT including SafeArrays.

The T() function converts a value to a specific VARIANT type. ex:

T(10, VT_BSTR)
PointOfLight · 18 Aug 2004, 03:00 UTC
Is the #IMPORT step required, or can you use a COM object without it? Also, any ETA on when this version will be arriving in our greedy little hands?
The #Import will create the list of defines (enum) and GUID's (dispatch) in PPL. That is all it does. No you don't need it if you don't want it.

ETA? I don't know, a couple more weeks. I have quite a bit of work to do... Here is a small list of the stuff I want to put in 0.8.

- Visual Form Builder on the pocketpc.
- Some enhancements to the Editor.ppl / Main.ppl.
- Finish activex / com. (90% done so far)
- "STRING" / 2 will result in "STR", "ING"
- "ABC" * 2 will result in "ABCABC"
- "ABCD" - "BC" will result in "AD"
- String$ = "POCKET"; String$[2,3] will result in "OCK" and String$[-1, 3] will result in "POC" and String$[3, -1] will result in "KET".
- Ability to use the console.ppl to issue PPL commands.
- Some enhancements and fixes to the PIDE.

Long list but other than the Visual Form Builder it will go pretty quickly I am pretty sure.
PointOfLight · 18 Aug 2004, 16:58 UTC
I like the "built in" Mid function on the string index. That's a pretty cool feature.
Don't tell anyone I got the idea from a cool little unix/pc language called LUA. :wink:
PointOfLight · 19 Aug 2004, 05:18 UTC
Hey, whatever works! I've never used LUA, but I think I've got it bookmarked somewhere...
PointOfLight · 20 Aug 2004, 18:53 UTC
kornalius wrote:
#IMPORT "activex.dll"
CreateObject("clsid or progid")
Invoke(objecthandle$, "method name", [parameters...])
GetProperty(objecthandle$, "property name")
SetProperty(objecthandle$, "property name", value)
T(Value, VariantType)
CreateSafeArray()
SafeArrayDestroy()


I could be just missing something here, but I think there is one important part left out of the COM equation. How do you respond to events that are fired by the COM object?
This is something I will have to look into. I also have to make sure things like (Fields[]) works in PPL. I don't know how I will implement these yet.

COM is a real nightmare to implement in a language, worse piece of technology ever created. The idea behind it is decent but the execution is one of Microsoft's usual business, it doesn't follow the rules most of the times.