launching web browser

khl623
10-05-2001, 03:54 AM
I'm writing an application that needs to launch the web browser (ie or netsacape) when a button is pressed. I tried ShellExecute to launch the IE but I also want to know if it is possible to launch the browser to navigate to a URL together with post data and http header? (something like Yahoo messenger). Thanks in advance

Ad1
10-05-2001, 04:07 AM
here's some info from the API guide, put the url in lpfile, as lpfile is not an exe I don't think you can pass parameters
<font color=green>Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As

· hwnd
Specifies a parent window. This window receives any message boxes that an application produces. For example, an application may report an error by producing a message box.

· lpOperation
Pointer to a null-terminated string that specifies the operation to perform. The following operation strings are valid:
“open”
The function opens the file specified by lpFile. The file can be an executable file or a document file. The file can be a folder to open.
“print”
The function prints the file specified by lpFile. The file should be a document file. If the file is an executable file, the function opens the file, as if “open” had been specified.
“explore”
The function explores the folder specified by lpFile.

The lpOperation parameter can be NULL. In that case, the function opens the file specified by lpFile.

· lpFile
Pointer to a null-terminated string that specifies the file to open or print or the folder to open or explore. The function can open an executable file or a document file. The function can print a document file.

· lpParameters
If lpFile specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies parameters to be passed to the application.
If lpFile specifies a document file, lpParameters should be NULL.

· lpDirectory
Pointer to a null-terminated string that specifies the default directory.</font color=green>

good luck

khl623
10-05-2001, 04:20 AM
I am able to launch the IE with ShellExecute but can I pass a http header and post data as well to the IE?

Ad1
10-05-2001, 04:33 AM
I don't think so but I don't know for sure, you may want to try using the CreateProcess API which does pretty much the same but allows you to pass more parameters,

if you don't already have it then I'd recommend you download the API Guide (http://www.allapi.net) for all the information you need

ChiefRedBull
10-05-2001, 06:14 AM
You can pass data through the URL you send IE towards. IF you format it correctly, then ShellExecute should do fine.
Eg - http://www.visualbasicforum.com/bbs/newreply.php?Cat=&Board=visbas&Number=54485&page=0&view=collapsed&what=showflat&sb=5&o=14&part=1&vc=1

This url passes data to the server -
<font color=red>Board=visbas
Number=54485</font color=red>
etc...

If you had a var <font color=red>sInfo</font color=red> you could pass it to the appropriate script using a URL like this:
<font color=red>http://www.whatever.com/whatever.pl?varName=sInfo</font color=red>

Chief


"How are we to learn, if those that know will not teach... ?" - Me.

khl623
10-08-2001, 01:40 AM
Thanks Chief, how about sending post data instead of get data?

ChiefRedBull
10-08-2001, 11:35 AM
I think its the same.
Heres a nice extract from Google.

<font color=red><pre>Firstly, the the HTTP protocol specifies differing usages for the two
methods. GET requests should always be idempotent on the server.
This means that whereas one GET request might (rarely) change some state
on the Server, two or more identical requests will have no further effect.

This is a theoretical point which is also good advice in practice.
If a user hits "reload" on his/her browser, an identical request will be
sent to the server, potentially resulting in two identical database or
guestbook entries, counter increments, etc. Browsers may reload a
GET URL automatically, particularly if cacheing is disabled (as is usually
the case with CGI output), but will typically prompt the user before
re-submitting a POST request. This means you're far less likely to get
inadvertently-repeated entries from POST.

GET is (in theory) the preferred method for idempotent operations, such
as querying a database, though it matters little if you're using a form.
There is a further practical constraint that many systems have builtin
limits to the length of a GET request they can handle: when the total size
of a request (URL+params) approaches or exceeds 1Kb, you are well-advised
to use POST in any case.

In terms of mechanics, they differ in how parameters are passed to the
CGI script. In the case of a POST request, form data is passed on
STDIN, so the script should read from there (the number of bytes to be
read is given by the Content-length header). In the case of GET, the
data is passed in the environment variable QUERY_STRING. The content-type
(application/x-www-form-urlencoded) is identical for GET and POST requests.

</pre></font color=red>

Chief


"How are we to learn, if those that know will not teach... ?" - Me.

Thinker
10-08-2001, 08:54 PM
Actually, Post data is in a header rather than in the URL. I have no idea
with the web browser. With the Internet Transfer Control I would do it
like
<pre>
Inet1.Execute , "POST", "user=me&pass=password&status=user", _
"Content-Type: application/x-www-form-urlencoded"


</pre>
This creates the correctly formatted header - I am not sure what it looks
like.

I think therefore I am... sometimes right. images/icons/wink.gif

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum