Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to access a URL

Status
Not open for further replies.

Han777

Programmer
Dec 12, 2007
19
I have written a working Delphi dll and want to add code in it to access a URL under certain conditions. Once the condition has occurred can I access the URL with a line or two of code? Do I need to add Uses? Could someone give me a sample of what that line or two would look like?
 
It depends on exactly what you mean by "access the URL".

It is not possible for anyone to acknowledge truth when their salary depends on them not doing it.
 
It's pretty easy to use Indy's TidHTTP component. It's Get method allows you to retrieve the contents of any URL. This is if you want the source of a page, rather than a HTML render of the URL.
 
Thanks for the timely responses. Sorry I wasn't more clear. I already know the URL I want to open under certain circumstances and can hard code that into my DLL . What I need is the way to ping that hard coded URL when those circumstances occur. By ping I mean open that URL in a browser when so directed by my dll.
 
Following the link I have modified the dll from which I want to open a known URL the address of which is hard-coded into my dll. With ShellApi included under USES I received errors in response to this test code line:
ShellExecute(Handle, 'open', ' SW_SHOWNORMAL) ;

The errors were:
[Error] OrdMgr_EntryOrder.pas(137): E2003 Undeclared identifier: 'Handle'
[Error] OrdMgr_EntryOrder.pas(137): E2003 Undeclared identifier: 'SW_SHOWNORMAL'

What's wrong with my code?
 
Your first error deals with the fact that from your dll, the handle to your form is undefined. The dll and your application are not in the same address space, so using handle is undefined from your dll. The handle can be null, so it may be ok to just put zero (0) rather than a Handle.

Your second error is due to the fact that you do not include the unit where SW_SHOWNORMAL is declared. Include 'Windows' in the uses clause or you can put in the value that SW_SHOWNORMAL is defined to be: 1

Here is a list of the values defined:

{$EXTERNALSYM SW_HIDE}
SW_HIDE = 0;
{$EXTERNALSYM SW_SHOWNORMAL}
SW_SHOWNORMAL = 1;
{$EXTERNALSYM SW_NORMAL}
SW_NORMAL = 1;
{$EXTERNALSYM SW_SHOWMINIMIZED}
SW_SHOWMINIMIZED = 2;
{$EXTERNALSYM SW_SHOWMAXIMIZED}
SW_SHOWMAXIMIZED = 3;
{$EXTERNALSYM SW_MAXIMIZE}
SW_MAXIMIZE = 3;
{$EXTERNALSYM SW_SHOWNOACTIVATE}
SW_SHOWNOACTIVATE = 4;
{$EXTERNALSYM SW_SHOW}
SW_SHOW = 5;
{$EXTERNALSYM SW_MINIMIZE}
SW_MINIMIZE = 6;
{$EXTERNALSYM SW_SHOWMINNOACTIVE}
SW_SHOWMINNOACTIVE = 7;
{$EXTERNALSYM SW_SHOWNA}
SW_SHOWNA = 8;
{$EXTERNALSYM SW_RESTORE}
SW_RESTORE = 9;
{$EXTERNALSYM SW_SHOWDEFAULT}
SW_SHOWDEFAULT = 10;
{$EXTERNALSYM SW_MAX}
SW_MAX = 10;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top