Login
`
Templates, Tools and Utilities
|
||
Icetips Article
Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
COM: Example of COM to create shortcuts 2004-01-14 -- Carl Barnes Newsgroups: sv.clarion.documentation
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.
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.
2. The SVCOM looks like it's based on Plugware com with some of the names changed.
3. At ThinkData are the docs to OutlookFUSe that provide some useful overview
of the COM classes but more is needed
4. One nice thing about Alexey's code is he tended to use all the native class
declare code with minimal changes. Then he added equates and structures where
required to make it work. I tried to leave it that way, but changed a few
things for the wrong reasons.
I also created a See Shortcut PRJ example that uses the ShellLink class to Load
the shortcut properties and display them. Not really polished but it proves the
.Get methods work
Here's the basic code to add a shortcut:
program
include 'xshell.inc'
MAP.
Hr HRESULT
COMIniter CCOMIniter !From SVCom to init COM
ShellLink CShellLink
LnkName string(260)
code
IF NOT COMIniter.IsInitialised()
HALT(,'OLE Initialization Failed', 'Error', ICON:Hand)
END
hr = ShellLink.init()
if hr <> S_Ok
HALT(,'ShellLink failed to init ' & hr )
end
hr = ShellLink.SetPath ('C:\WINDOWS\CALC.EXE')
IF hr<>S_OK then Message('SetPath hr=' & hr ).
hr = ShellLink.SetIconLocation ('C:\WINDOWS\CALC.EXE', 0)
IF hr<>S_OK then Message('SetIconLocation hr=' & hr ).
hr = ShellLink.SetDescription ('Calculator, natch!')
IF hr<>S_OK then Message('SetDescription hr=' & hr ).
! hr = ShellLink.SetHotKey ( )
! IF hr<>S_OK then Message('SetHotKey hr=' & hr ).
hr = ShellLink.SetWorkingDir ('C:\WINDOWS')
IF hr<>S_OK then Message('SetWorkingDir hr=' & hr ).
hr = ShellLink.SaveShortCut2Desktop ('Calculator XShell2.LNK',LnkName)
IF hr<>S_OK then
Message('SaveShortCut2Desktop hr=' & hr )
else
Message('all done LnkName=' & LnkName )
end
Download
comshellexam.zip
Today is November 21, 2024, 3:33 am This article has been viewed 35451 times. Google search has resulted in 89 hits on this article since January 25, 2004.
|
|