Article View: borland.public.cppbuilder.nativeapi
Article #8055Re: Start and stop application
From: Remy Lebeau (TeamB)
Date: Fri, 26 Nov 2004 22:43
Date: Fri, 26 Nov 2004 22:43
64 lines
3027 bytes
3027 bytes
"Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> wrote in
message news:41a72da6$1@newsgroups.borland.com...
> To get the full path to the default .PDF handling application,
> read the relevant Registry key, like this :-
You should use FindExecutable() instead of reading the Registry manually.
The settings could be stored in multiple Registry keys that Windows chooses
from when launching the file.
> TRegistry *mjtreg=new TRegistry();
> mjtreg->RootKey=HKEY_CLASSES_ROOT;
> if
>
(mjtreg->OpenKeyReadOnly("AcroExch.Document\\protocol\\StdFileEditing\\serve
r"
> ))
> ShowMessage("Acrobat is "+mjtreg->ReadString(""));
> else ShowMessage("You have not installed Acrobat Reader.");
> delete mjtreg;
That is not the correct way to read the default application from the
Registry. You need to read the ".pdf" key first to find out which other key
the settings are stored in. Then you need to read the "shell\open\command"
key instead of the "protocol\StdFileEditing\server" key. For example:
TRegistry *mjtreg = new TRegistry;
try
{
mjtreg->RootKey = HKEY_CLASSES_ROOT;
AnsiString AcrobatPath;
if( mjtreg->OpenKeyReadOnly("\\.pdf") )
{
AnsiString ProgID = mjtreg->ReadString("");
if( !ProgID.IsEmpty() )
{
if( mjtreg->OpenKeyReadOnly("\\" + ProgID +
"\\shell\\open\\command") )
AcrobatPath = mjtreg->ReadString("");
}
mjtreg->CloseKey();
}
if( !AcrobatPath.IsEmpty() )
{
if( AcrobatPath.Pos("%1") == 0 )
AcrobatPath += " \"your document here.pdf\"";
else
AcrobatPath = StringReplace(AcrobatPath, "%1", "your
document here.pdf", TReplaceFlags());
// use AcrobatPath as neded...
}
else
ShowMessage("You have not installed Acrobat Reader.");
}
__finally {
delete mjtreg;
}
Gambit
Technical Details
Message-ID:
<41a7b111@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<41a713ab@newsgroups.borland.com> <41a72da6$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,44eef0c11b4047c0 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <41a713ab@newsgroups.borland.com> <41a72da6$1@newsgroups.borland.com> Subject: Re: Start and stop application Date: Fri, 26 Nov 2004 14:43:35 -0800 Lines: 66 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <41a7b111@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1101508881 68.69.17.41 (26 Nov 2004 14:41:21 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!news-peer0-test!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail