` Printed Icetips Article

Icetips Article



COM: Example
2004-01-16 -- Carl Barnes
 
Newsgroups: sv.clarion.documentation


For completeness I'll report Andy I's public post and attach some shell COM
files he generated and attached
---------------------------

>From Carl Barnes on the SV Discuss Box:

Hi Carl,

I do not have access to the NG where you asked for my help. I will respond
here without knowing what it is you need from me in entirety.

>FWIW attached is my example of using the SVCom to Add a Shortcut. It's
>Alexey's code converted. I enhanced to wrap it all in a Class and
encapsulated all
>interface calls into class methods. It's not really polished and finished,
I
>got it working and tried to use as many SV equates as I could.
>While this works fine for me I'm not sure if I have handled the COM object
>correctlty. Maybe if AndyI is in this group he could take a look.

Ok. Code looks reasonable albeit that the save method is not native as it
takes only one param which is a variant. Without seeing what they are doing
in some of the calls, there is no way to know for sure if the code is
correct. But if it works, I guess it must be. Incidently, COMIniter is COM
(CoInitialize) not OLE (OleInitialize). OLE goes way beyond COM. The Objects
will auto clean on destruct so in principle it looks fine.

>A few reflections:
>1. It's a damn lot of work. Some auto gen of the code would help. My
>wrapping it all in a Class mainly takes care of type conversions.

Attached. That's why we have helpers. Then it's a lot less work. For
example....

sz = 'c:\winnt\calc.exe'
hr = ShellLink.put_Path(_bstr(sz))
if hr ~= S_OK
message(hr)
return
end

Not too difficult at all.

>2. The SVCOM looks like it's based on Plugware com with some of the names
>changed.

Yes, I wrote it, albeit an old obsolete copy that still has quite a few
bugs.

>3. At ThinkData are the docs to OutlookFUSe that provide some useful
>overview of the COM classes but more is needed

I have a doc somewhere but I lost a fair amount when my dev machine crashed.
The only thing we never lost were the sources in source control. Russ has
the best docs at this time on COM in clarion both from our ETC presentations
and one of his classes.

Regards

Andy

Attachment: shell32.clw (30 KB)
Attachment: shell32.inc (23 KB)
Attachment: shl32def.inc (4,997 bytes)
Attachment: shl32iid.inc (10 KB)
Attachment: shl32int.inc (14 KB)

Download andyipost.zip


softvelocity.public.clarion6 (softvelocity.public.clarion6) - Subject: Re:Att Carl Barnes From: Carl Barnes Thu, Jan 15 2004 1:18 pm Article List Close Reply Edit Previous in Thread Next in Thread View Thread Watch Thread Ignore Thread Delete Thanks for the quick reply. No time today but will review it closely tomorrow. Your classes don't have IShellLink but have IShellLinkDual. I prefer to stay away from the extra complexity of variants in IDispatch interfaces. I cannot seem to find Type Lib stuff for some of the Shell interfaces like IShellLink. Is it possible that the definitions only exist in WinSDK\Includes\ShlObj.h ? It has IShellLink and others like IProgressDialog. The OleInitialize you refer to I think you found in Alexey's original code? He named a method OLEInit.Construct even though it called CoInitialize. And he also named IUnknown as IOLE which was a little odd. With some name changes its a great little COM example. What is a LPCOLESTR? Alexey uses a BSTRING so I just left it that way. E.g. IPersistFile::Save HRESULT Save( LPCOLESTR pszFileName, BOOL fRemember ); ============================= softvelocity.public.clarion6 (softvelocity.public.clarion6) - Subject: Re: Re:Att Carl Barnes From: "AndyI" Thu, Jan 15 2004 1:53 pm Article List Close Reply Previous in Thread Next in Thread View Thread Watch Thread Ignore Thread Hi Carl, > Thanks for the quick reply. No time today but will review it closely tomorrow. > > Your classes don't have IShellLink but have IShellLinkDual. I prefer to stay > away from the extra complexity of variants in IDispatch interfaces. IShellLinkDual is the same as IShellLink. That came from my shell32.dll. Although my OS is a little strange and is in need of reinstalling. Dual means it's a dual interface i.e early bound rather than a dispatch interface which is otherwise known as an automation interface which is late bound via IDispatch. > The OleInitialize you refer to I think you found in Alexey's original code? He > named a method OLEInit.Construct even though it called CoInitialize. And he > also named IUnknown as IOLE which was a little odd. With some name changes its > a great little COM example. No you had that as a comment. > What is a LPCOLESTR? Alexey uses a BSTRING so I just left it that way. E.g. > IPersistFile::Save > HRESULT Save( > LPCOLESTR pszFileName, > BOOL fRemember > ); They are the same thing. Regards Andy



Printed May 5, 2024, 6:15 am
This article has been viewed/printed 35124 times.
Google search has resulted in 263 hits on this article since January 25, 2004.