Thread overview
COM type library importer
Apr 09, 2006
John C
Apr 10, 2006
r
Apr 10, 2006
John C
Apr 11, 2006
r
Apr 11, 2006
Carlos Santander
Apr 11, 2006
John C
Apr 12, 2006
John C
April 09, 2006
I've written an experimental tool that creates a D import module from a COM type library.

It should save you from having to convert C headers for COM programming.

Command line options that control the generated source code include:
	/comments - adds type library's helpstrings as comments
	/noenums - omits enum names
	/tabs - uses tabs to indent instead of spaces
	/indent - 10 or fewer indents
	/propget and /propput - prefixes for COM property accessors
	/module - the name of the generated module

Try it out (at your own risk - this is, as I've said, experimental).
http://www.paperocean.org/d/tlibd/

John.
April 10, 2006
Whooohooo!

Many thanks.  I'll test it out and let you know how it goes.

Tom


In article <e1b3tk$2etj$1@digitaldaemon.com>, John C says...
>
>I've written an experimental tool that creates a D import module from a COM type library.
>
>It should save you from having to convert C headers for COM programming.
>
>Command line options that control the generated source code include:
>	/comments - adds type library's helpstrings as comments
>	/noenums - omits enum names
>	/tabs - uses tabs to indent instead of spaces
>	/indent - 10 or fewer indents
>	/propget and /propput - prefixes for COM property accessors
>	/module - the name of the generated module
>
>Try it out (at your own risk - this is, as I've said, experimental). http://www.paperocean.org/d/tlibd/
>
>John.


April 10, 2006
In article <e1b3tk$2etj$1@digitaldaemon.com>, John C says...
>
>I've written an experimental tool that creates a D import module from a COM type library.
>
>It should save you from having to convert C headers for COM programming.
>
>Command line options that control the generated source code include:
>	/comments - adds type library's helpstrings as comments
>	/noenums - omits enum names
>	/tabs - uses tabs to indent instead of spaces
>	/indent - 10 or fewer indents
>	/propget and /propput - prefixes for COM property accessors
>	/module - the name of the generated module
>
>Try it out (at your own risk - this is, as I've said, experimental). http://www.paperocean.org/d/tlibd/
>
>John.

this is great!
but seems i am not smart enough to use it properly. i ran the program on
msado15.dll and added the missing enums.

when i try to use the following

_Connection oDatabase = Connection.create!(_Connection);

oDatabase will always be null. the same is for

_Recordset oRecords = Recordset.create!(_Recordset);


could you give me some pointers?

thanx
r


April 10, 2006
r wrote:
> In article <e1b3tk$2etj$1@digitaldaemon.com>, John C says...
> 
>>I've written an experimental tool that creates a D import module from a COM type library.
>>
>>It should save you from having to convert C headers for COM programming.
>>
>>Command line options that control the generated source code include:
>>	/comments - adds type library's helpstrings as comments
>>	/noenums - omits enum names
>>	/tabs - uses tabs to indent instead of spaces
>>	/indent - 10 or fewer indents
>>	/propget and /propput - prefixes for COM property accessors
>>	/module - the name of the generated module
>>
>>Try it out (at your own risk - this is, as I've said, experimental).
>>http://www.paperocean.org/d/tlibd/
>>
>>John.
> 
> 
> this is great! but seems i am not smart enough to use it properly. i ran the program on
> msado15.dll and added the missing enums.
> 
> when i try to use the following
> 
> _Connection oDatabase = Connection.create!(_Connection);
> 
> oDatabase will always be null. the same is for 
> 
> _Recordset oRecords = Recordset.create!(_Recordset);
> 
> 
> could you give me some pointers?
> 
> thanx
> r
> 
> 

I'll be uploading a bug-fixed version shortly which correctly generates enums.

Ensure you're initializing COM with CoInitialize. I usually do so in a static module ctor, like this:

	module main;

	import com;

	static this() {
		CoInitialize(null);
	}

	static ~this() {
		CoUninitialize();
	}

Hope that helps.
April 11, 2006
In article <e1eeha$di6$1@digitaldaemon.com>, John C says...
>
>r wrote:
>> In article <e1b3tk$2etj$1@digitaldaemon.com>, John C says...
>> 
>>>I've written an experimental tool that creates a D import module from a COM type library.
>>>
>>>It should save you from having to convert C headers for COM programming.
>>>
>>>Command line options that control the generated source code include:
>>>	/comments - adds type library's helpstrings as comments
>>>	/noenums - omits enum names
>>>	/tabs - uses tabs to indent instead of spaces
>>>	/indent - 10 or fewer indents
>>>	/propget and /propput - prefixes for COM property accessors
>>>	/module - the name of the generated module
>>>
>>>Try it out (at your own risk - this is, as I've said, experimental). http://www.paperocean.org/d/tlibd/
>>>
>>>John.
>> 
>> 
>> this is great!
>> but seems i am not smart enough to use it properly. i ran the program on
>> msado15.dll and added the missing enums.
>> 
>> when i try to use the following
>> 
>> _Connection oDatabase = Connection.create!(_Connection);
>> 
>> oDatabase will always be null. the same is for
>> 
>> _Recordset oRecords = Recordset.create!(_Recordset);
>> 
>> 
>> could you give me some pointers?
>> 
>> thanx
>> r
>> 
>> 
>
>I'll be uploading a bug-fixed version shortly which correctly generates enums.
>
>Ensure you're initializing COM with CoInitialize. I usually do so in a static module ctor, like this:
>
>	module main;
>
>	import com;
>
>	static this() {
>		CoInitialize(null);
>	}
>
>	static ~this() {
>		CoUninitialize();
>	}
>
>Hope that helps.

thanx, it helped.

r


April 11, 2006
John C escribió:
> 
> Ensure you're initializing COM with CoInitialize. I usually do so in a static module ctor, like this:
> 
>     module main;
> 
>     import com;
> 
>     static this() {
>         CoInitialize(null);
>     }
> 
>     static ~this() {
>         CoUninitialize();
>     }
> 

A suggestion: wouldn't it be better to have those in your com module? I mean, they're going to be needed anyway, so why not make things easier for users?

-- 
Carlos Santander Bernal
April 11, 2006
Carlos Santander wrote:
> John C escribió:
> 
>>
>> Ensure you're initializing COM with CoInitialize. I usually do so in a static module ctor, like this:
>>
>>     module main;
>>
>>     import com;
>>
>>     static this() {
>>         CoInitialize(null);
>>     }
>>
>>     static ~this() {
>>         CoUninitialize();
>>     }
>>
> 
> A suggestion: wouldn't it be better to have those in your com module? I mean, they're going to be needed anyway, so why not make things easier for users?
> 

I agree. I'll make the change.
April 12, 2006
TLibD v0.15 is now ready. I've been concentrating on making it generate code that can be compiled without errors or having to hand-edit it.

The zip file contains the source code if you're wondering how it's done. It's not too pretty, though.

http://www.paperocean.org/d/tlibd/

John.