Thread View: borland.public.cppbuilder.nativeapi
8 messages
8 total messages
Started by Tom
Sat, 25 Mar 2006 09:06
shellexecute
Author: Tom
Date: Sat, 25 Mar 2006 09:06
Date: Sat, 25 Mar 2006 09:06
27 lines
1730 bytes
1730 bytes
I have made a help file for my application in .pdf format. I use the
following command to open it on help button click:
ShellExecute(0, "open", "help//help.pdf", NULL, NULL, SW_SHOWNORMAL)
How do I know if that file has been opened, I tried with following:
if (!ShellExecute(0, "open", "help//help.pdf", NULL, NULL, SW_SHOWNORMAL))
Application->MessageBox("You need Acrobat Reader for viewing
help","Information");
but it doesn't work, also I've tried
try
{
ShellExecute(0, "open", "help//pomoc.pde", NULL, NULL, SW_SHOWNORMAL))
}
catch(...)
{
Application->MessageBox("You need Acrobat Reader for viewing
help","Information");
}
it also doesn't work. I just want to know if end user opened the file,
and if he didn't I want to give him message to inform him that help is
in Acrobat Reader format and he needs to install it in order to read help.
Re: shellexecute
Author: Hans Galema
Date: Sat, 25 Mar 2006 10:56
Date: Sat, 25 Mar 2006 10:56
28 lines
1638 bytes
1638 bytes
Tom wrote:
> ShellExecute(0, "open", "help//help.pdf", NULL, NULL, SW_SHOWNORMAL)
That should be
ShellExecute(0, "open", "help/help.pdf", NULL, NULL, SW_SHOWNORMAL)
or
ShellExecute(0, "open", "help\\help.pdf", NULL, NULL, SW_SHOWNORMAL)
> How do I know if that file has been opened,
As the help states ShellExecute returns a HINSTANCE. If its value as int
is <= 32 then it did not succeed.
HINSTANCE hinstance = ShellExecute ( .... );
if ( (int)hinstance <= 32 )
{
// not done
}
> Application->MessageBox("You need Acrobat Reader for viewing help","Information");
Well the user would only need a pdf reader.
Hans.
Re: shellexecute
Author: Ed Mulroy
Date: Sat, 25 Mar 2006 11:03
Date: Sat, 25 Mar 2006 11:03
57 lines
3035 bytes
3035 bytes
I don't think default directory should be NULL. It might need to be
".\\help" (don't overlook the leading period in that string).
The name of the file to execute is shown as "help//help.pdf". Slashes are
doubled in a string only if they are backslashes. You used forward slashes,
correct for some operating systems such as Linux or one of the Unixes but
only begrudgingly accepted some places and not others by Windows. Either
use one forward slash or a doubled backslash.
The return value is not zero for failure except in the case of when the
operating system has run out of memory or resources. An error is indicated
by a return value of 32 or less. The code you show would not trigger the
message box on error except when memory or resources are exhausted.
Otherwise it would fail quietly, the exact behavior you report.
init result = (int) ::ShellExecute(
0, "open", "help\\help.pdf", NULL,
".\\help", SW_SHOWNORMAL)
if (result <= 32)
{
Application->MessageBox(
"You need Acrobat Reader for viewing help",
"Information");
}
. Ed
> Tom wrote in message
> news:442507f8@newsgroups.borland.com...
>I have made a help file for my application in .pdf format. I use the
>following command to open it on help button click:
>
> ShellExecute(0, "open", "help//help.pdf", NULL, NULL, SW_SHOWNORMAL)
>
>
> How do I know if that file has been opened, I tried with following:
>
> if (!ShellExecute(0, "open", "help//help.pdf", NULL, NULL, SW_SHOWNORMAL))
> Application->MessageBox("You need Acrobat Reader for viewing
> help","Information");
>
> but it doesn't work, also I've tried
>
> try
> {
> ShellExecute(0, "open", "help//pomoc.pde", NULL, NULL, SW_SHOWNORMAL))
> }
> catch(...)
> {
> Application->MessageBox("You need Acrobat Reader for viewing
> help","Information");
> }
>
> it also doesn't work. I just want to know if end user opened the file, and
> if he didn't I want to give him message to inform him that help is in
> Acrobat Reader format and he needs to install it in order to read help.
Re: shellexecute
Author: Hans Galema
Date: Sat, 25 Mar 2006 11:04
Date: Sat, 25 Mar 2006 11:04
14 lines
1486 bytes
1486 bytes
Ed Mulroy wrote: > I don't think default directory should be NULL. It might need to be > ".\\help" (don't overlook the leading period in that string). Good point. But maybe better it is to just use an absolute path for the filename. AnsiString FileName = ExtractFilePath (ParamStr(0)) + "help\\help.pdf"; ShellExecute(0, "open", FileName.c_str(), NULL, NULL, SW_SHOWNORMAL) Hans.
Re: shellexecute
Author: Vladimir Stefanovic
Date: Sat, 25 Mar 2006 11:20
Date: Sat, 25 Mar 2006 11:20
13 lines
1106 bytes
1106 bytes
Off topic: > ShellExecute(0, "open", "help//pomoc.pde", NULL, NULL, SW_SHOWNORMAL)) pomoc.pdf ? You speek Serbian/Croation :) ? -- Best Regards, Vladimir Stefanovic
Re: shellexecute
Author: Tom
Date: Sat, 25 Mar 2006 13:33
Date: Sat, 25 Mar 2006 13:33
19 lines
1713 bytes
1713 bytes
Well, I want to thank both, ED & Hans on your help, your suggestions solved my problem and did exactly what I needed. Thanks again. Hans Galema wrote: > Ed Mulroy wrote: >> I don't think default directory should be NULL. It might need to be >> ".\\help" (don't overlook the leading period in that string). > > Good point. > > But maybe better it is to just use an absolute path for the > filename. > > AnsiString FileName = ExtractFilePath (ParamStr(0)) + "help\\help.pdf"; > > ShellExecute(0, "open", FileName.c_str(), NULL, NULL, SW_SHOWNORMAL) > > Hans.
Re: shellexecute
Author: Tom
Date: Sat, 25 Mar 2006 13:40
Date: Sat, 25 Mar 2006 13:40
17 lines
1331 bytes
1331 bytes
yes, I'm from croatia. Off topic: Mislim da ne smijem pisati na hrvatskom, ali svejedno pozdravljam te i hvala ti sto si mi pomagao na ADO news grupi. Jos jednom hvala i pozdrav. Vladimir Stefanovic wrote: > Off topic: > >> ShellExecute(0, "open", "help//pomoc.pde", NULL, NULL, SW_SHOWNORMAL)) > > pomoc.pdf ? > > You speek Serbian/Croation :) ? > > >
Re: shellexecute
Author: Vladimir Stefanovic
Date: Sat, 25 Mar 2006 17:27
Date: Sat, 25 Mar 2006 17:27
19 lines
1445 bytes
1445 bytes
> Off topic: > Mislim da ne smijem pisati na hrvatskom, ali svejedno > pozdravljam te i hvala ti sto si mi pomagao na ADO news > grupi. Jos jednom hvala i pozdrav. Off topic: Nema na cemu :) Inace uvek koristi PUNE putanje kada je u pitanju C++ Builder kao sto je rekao Hans. Na primer TOpenDialog/TSaveDialog mogu tvoj ROOT da promene, pa ono sto je nekada radilo (sa 'obicnom' putanjom) vise nece... Pozdrav. -- Best Regards, Vladimir Stefanovic
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads