Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Windos
win32.3rdparty
win32.directx.audio
win32.directx.ddk
win32.directx.graphics
win32.directx.input
win32.directx.managed
win32.directx.misc
win32.directx.networking
win32.directx.sdk
win32.directx.video
win32.dirx.grap.shaders
win32.gdi
win32.international
win32.kernel
win32.messaging
win32.mmedia
win32.networks
win32.ole
win32.rtc
win32.tapi
win32.tapi.beta
win32.tools
win32.ui
win32.wince
win32.wmi
windows.mediacenter
winfx.aero
winfx.announcements
winfx.avalon
winfx.collaboration
winfx.fundamentals
winfx.general
winfx.indigo
winfx.sdk
winfx.winfs
  
 
date: Thu, 3 Jul 2008 14:06:01 -0700,    group: microsoft.public.win32.programmer.ole        back       


Few small questions about COM   
I have just started reading COM and I need to clear some concept. So, need 
help form you guys! 
Firstly, I am wondering why do we need to create .DEF file? Is it required 
only for Dynamic Load libraries?

Secondly, when using local servers (exe), is it really required to register 
the exe and the proxy DLL even when nothing has been changed at the COM 
front. Registering it is no harm, but is it really required?

Thirdly, on the system on which COM server (exe) is running do we need to 
register the proxy DLL? If yes what entries in the registry are created? On 
the COM client system which will consume this COM component, is registering 
only with the proxy sufficient?

Thanks,
Jeff
date: Thu, 3 Jul 2008 14:06:01 -0700   author:   Jeff Autery

Re: Few small questions about COM   
Jeff Autery  wrote:
> Firstly, I am wondering why do we need to create .DEF file? Is it
> required only for Dynamic Load libraries?

This has little to do with COM. You need DEF file to list functions you 
want exported from your DLL. It so happens that a COM server packaged in 
a DLL has to export a few functions under predefined names.

> Secondly, when using local servers (exe), is it really required to
> register the exe and the proxy DLL even when nothing has been changed
> at the COM front. Registering it is no harm, but is it really
> required?

I'm not familiar with the term "COM front". What exactly has and has not 
changed?

If you have already registered your server before, and only changed some 
implementation details but not the interface, you don't need to register 
it again, if that's what you are asking.

> Thirdly, on the system on which COM server (exe) is running do we
> need to register the proxy DLL?

Yes.

> If yes what entries in the registry
> are created?

HKCR\Interface\{Interface IID}\ProxyStubClsid32

and a few other subkeys under {IID} key.

> On the COM client system which will consume this COM
> component, is registering only with the proxy sufficient?

Yes, if the client is willing to use CoCreateInstanceEx and specify 
certain information in COSERVERINFO structure that would otherwise be 
looked up in the registry.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 3 Jul 2008 17:26:02 -0400   author:   Igor Tandetnik

Re: Few small questions about COM   
You don't need a def file and Microsoft recomends not using one. You do have 
to export symbols as Igor says. You should use __declspec(dllexport) to 
export symbols.

You should learn about DLLs in general. See "Dynamic-Link Libraries" at:
http://msdn2.microsoft.com/en-us/library/ms682589.aspx


"Jeff Autery"  wrote in message 
news:80209F91-FDB2-498C-B3F6-FB682A435AAE@microsoft.com...
> Firstly, I am wondering why do we need to create .DEF file? Is it required
> only for Dynamic Load libraries?
date: Fri, 4 Jul 2008 12:21:09 -0700   author:   Sam Hobbs _change_social_to_socal

Re: Few small questions about COM   
"Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in
message news:O8R%23%239h3IHA.4272@TK2MSFTNGP03.phx.gbl
> You don't need a def file and Microsoft recomends not using one. You
> do have to export symbols as Igor says. You should use
> __declspec(dllexport) to export symbols.

It's impossible with __declspec(dllexport) to export undecorated 
symbols, as far as I know. That's why you need a DEF file.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Fri, 4 Jul 2008 18:16:26 -0400   author:   Igor Tandetnik

Re: Few small questions about COM   
"Igor Tandetnik"  wrote in message 
news:OvJDeOi3IHA.2348@TK2MSFTNGP06.phx.gbl...
> "Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in
> message news:O8R%23%239h3IHA.4272@TK2MSFTNGP03.phx.gbl
>> You don't need a def file and Microsoft recomends not using one. You
>> do have to export symbols as Igor says. You should use
>> __declspec(dllexport) to export symbols.
>
> It's impossible with __declspec(dllexport) to export undecorated symbols, 
> as far as I know. That's why you need a DEF file.


Perhaps I misunderstand the question and your answers; I know that there are 
some circumsances where a def file is needed, but I forget what they are.

If "undecorated symbols" means C-style symbols (as in extern "C"), then 
__declspec(dllexport) works.
date: Fri, 4 Jul 2008 20:35:18 -0700   author:   Sam Hobbs _change_social_to_socal

Re: Few small questions about COM   
"Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in
message news:O1J5FSm3IHA.3500@TK2MSFTNGP05.phx.gbl
> "Igor Tandetnik"  wrote in message
> news:OvJDeOi3IHA.2348@TK2MSFTNGP06.phx.gbl...
>> "Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in
>> message news:O8R%23%239h3IHA.4272@TK2MSFTNGP03.phx.gbl
>>> You don't need a def file and Microsoft recomends not using one. You
>>> do have to export symbols as Igor says. You should use
>>> __declspec(dllexport) to export symbols.
>>
>> It's impossible with __declspec(dllexport) to export undecorated
>> symbols, as far as I know. That's why you need a DEF file.
>
>
> Perhaps I misunderstand the question and your answers; I know that
> there are some circumsances where a def file is needed, but I forget
> what they are.
> If "undecorated symbols" means C-style symbols (as in extern "C"),
> then __declspec(dllexport) works.

Try it.

__declspec(dllexport) STDAPI DllGetClassObject(
    REFCLSID rclsid,  REFIID riid,  LPVOID * ppv)
{}

Build a DLL with just this declaration, then check with Dependency 
Walker what name it exports. You'll find it to be something like 
"DllGetClassObject@12". COM requires that the exported funciton be named 
precisely DllGetClassObject.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Sat, 5 Jul 2008 11:55:27 -0400   author:   Igor Tandetnik

Re: Few small questions about COM   
Igor,

> > You don't need a def file and Microsoft recomends not using one. You
> > do have to export symbols as Igor says. You should use
> > __declspec(dllexport) to export symbols.
>
> It's impossible with __declspec(dllexport) to export undecorated
> symbols, as far as I know. That's why you need a DEF file.

You can use #pragma to export undecorated name.

#pragma comment(linker, "/EXPORT:DriverProc=_DriverProc@20,PRIVATE")

In this example you don't need to __declspec(dllexport) original
DriverProc since there would be two exports then, both decorated and
undecorated.

Roman
date: Sat, 5 Jul 2008 10:44:22 -0700 (PDT)   author:   Roman Ryl...

Re: Few small questions about COM   
"Igor Tandetnik"  wrote in message 
news:%23KcBQer3IHA.4036@TK2MSFTNGP02.phx.gbl...
> "Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in
> message news:O1J5FSm3IHA.3500@TK2MSFTNGP05.phx.gbl
>> "Igor Tandetnik"  wrote in message
>> news:OvJDeOi3IHA.2348@TK2MSFTNGP06.phx.gbl...
>>> "Sam Hobbs" <samuel@social.rr.com_change_social_to_socal> wrote in
>>> message news:O8R%23%239h3IHA.4272@TK2MSFTNGP03.phx.gbl
>>>> You don't need a def file and Microsoft recomends not using one. You
>>>> do have to export symbols as Igor says. You should use
>>>> __declspec(dllexport) to export symbols.
>>>
>>> It's impossible with __declspec(dllexport) to export undecorated
>>> symbols, as far as I know. That's why you need a DEF file.
>>
>>
>> Perhaps I misunderstand the question and your answers; I know that
>> there are some circumsances where a def file is needed, but I forget
>> what they are.
>> If "undecorated symbols" means C-style symbols (as in extern "C"),
>> then __declspec(dllexport) works.
>
> Try it.
>
> __declspec(dllexport) STDAPI DllGetClassObject(
>    REFCLSID rclsid,  REFIID riid,  LPVOID * ppv)
> {}
>
> Build a DLL with just this declaration, then check with Dependency Walker 
> what name it exports. You'll find it to be something like 
> "DllGetClassObject@12". COM requires that the exported funciton be named 
> precisely DllGetClassObject.

Certainly you know more about COM than I do; probably much more. It does 
seem strange to me however that Microsoft requires a Def file for COM 
objects as you show.

See "CodeProject: Introduction to COM Part II - Behind the Scenes of a COM 
Server" at:
http://www.codeproject.com/KB/COM/comintro2.aspx?display=Print

Near the end under "COM macros" it says:

"One downside to using STDAPI is that you can't use __declspec(dllexport) 
with it, because of how STDAPI expands. You instead have to export the 
function using a .DEF file."

So that it a possible explanation; that it is the STDAPI macro prevents use 
of __declspec(dllexport).
date: Sun, 6 Jul 2008 22:29:35 -0700   author:   Sam Hobbs _change_social_to_socal

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us