Article View: borland.public.cppbuilder.nativeapi
Article #10635Re: trying to acces to a file by means of a link file
From: Frank Chisme
Date: Tue, 06 Apr 2004 08:43
Date: Tue, 06 Apr 2004 08:43
119 lines
4499 bytes
4499 bytes
Hello Damon,
Now my compiler doesn�t give an error (with the NO_WIN32_LEAN_AND_MEAN
conditional), but the function:
if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink,
NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(void **)&psl))) {
gives an error (not SUCCEDDED). But I don�t know how to solve it, in fact, I
even don�t know which the error is. All I have achieved is to know that the
error si -2147221008
And how did you figure out that it was mandatory to establish the
NO_WIN32_LEAN_AND_MEAN conditional?
This is the code:
// grab a pointer to the IShellLink interface
class IShellLink * psl;
if (SUCCEEDED(CoCreateInstance(CLSID_ShellLink,
NULL,CLSCTX_INPROC_SERVER,IID_IShellLink,(void **)&psl))) {
// grab a pointer to the IPersistFile interface
LPPERSISTFILE lppf;
if (SUCCEEDED(psl->QueryInterface(IID_IPersistFile,reinterpret_cast<void
**>(&lppf)))) {
// for example...
AnsiString IconPath("lanzaapli.ini.lnk");
wchar_t wIconPath[MAX_PATH];
IconPath.WideChar(wIconPath, MAX_PATH);
// use the IPersistFile::Load function
// to load the shortcut
if (SUCCEEDED(lppf->Load(wIconPath, STGM_READ))) {
// use the IShellLink::Resolve function to
// resolve the link
if (SUCCEEDED(psl->Resolve(NULL, SLR_ANY_MATCH))) {
// get the path of the link's target
WIN32_FIND_DATA wfd;
char filename[MAX_PATH];
if (SUCCEEDED(psl->GetPath(filename, MAX_PATH,&wfd,
SLGP_UNCPRIORITY))) {
ShowMessage(filename);
}
}
}
// clean up
lppf->Release();
}
// clean up
psl->Release();
}
else {
MsgBoxError("CoCreateInstance");
}
Thank you Damon.
"Damon Chandler (TeamB)" <dmc27@cornell.edu> escribi� en el mensaje
news:406d644f$1@newsgroups.borland.com...
> Frank,
> <shlobj.h> is the header that you need. In order to use this header
> w/o compile-time errors in newer versions of BCB, you have to go to the
> "Directories/Conditionals" tab of the "Project Options" dialog, and then
> enter NO_WIN32_LEAN_AND_MEAN in the "Conditional defines" field. If
> this doesn't work for you, what's the error message that you're getting?
>
> --
> Damon (TeamB)
>
>
> Frank Chisme wrote:
> > Thank you Damon,
> >
> > I see that this is the way I have to follow, but now I have another
problem
> >
> > �Do you know which is the header I have to include to be able to use
> > IShellLink?
> > I am trying with #include <shlobj.hpp> and #include <shlobj.h>
> > and it doesn�t work.
> >
> > Thank you.
> >
> >
> >
> >
> >
> > "Damon Chandler (TeamB)" <dmc27@cornell.edu> escribi� en el mensaje
> > news:406cbe4b$1@newsgroups.borland.com...
> >
> >>Hi Frank,
> >> You can use the IShellLink COM interface to retrieve the
> >>path+filename of the file that the link refers to; see here for an
> >>example...
> >>
> >>http://tinyurl.com/2taea
> >>
> >>Good luck,
> >>--
> >>Damon (TeamB)
> >>
> >>
> >>Frank Chisme wrote:
> >>
> >>>where "fName" is "personal.ini.lnk".
> >>>And my application doesn�t get to personal.ini content.
> >>>�How can I access personal.ini file by means of personal.ini.lnk?
> >
> >
> >
Technical Details
Message-ID:
<40726d3a@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<406c1fc2$1@newsgroups.borland.com> <406cbe4b$1@newsgroups.borland.com> <406d38cc$1@newsgroups.borland.com> <406d644f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10cc67,a53a58dfad4a9f1a X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-04-06 01:55:16 PST From: "Frank Chisme" <frankchisme@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <406c1fc2$1@newsgroups.borland.com> <406cbe4b$1@newsgroups.borland.com> <406d38cc$1@newsgroups.borland.com> <406d644f$1@newsgroups.borland.com> Subject: Re: trying to acces to a file by means of a link file Date: Tue, 6 Apr 2004 10:43:29 +0200 Lines: 121 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 80.81.122.114 Message-ID: <40726d3a@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1081240890 80.81.122.114 (6 Apr 2004 01:41:30 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!border1.nntp.ash.giganews.com!border2.nntp.ash.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail