Page 1 of 1
creating an exe launcher !!!
Posted: Sun Jun 29, 2003 1:56 pm
by Large
Ok Guys,
I havn't a clue where to start on this one but hopefully if I tell you what I need one of you kind guys will give me an example.
I have built a company intranet and using PHP I have built a script that checks the users pop3 email box and returns the amount of emails into a variable, this displays on the screen like this :
Email Inbox : 3
Now what I need to be able to do is click on a hyperlink and launch an exe (ie : if you click on the Email Inbox words it launches Outlook Express), you can not do this in web language ( PHP, Javascript, etc ) so I was wondering is it possible to build an active X control in PB that will launch my desired application from a hyperlink.
I really have not got a clue, so please be kind and give me some example on how to achieve this.
Kind regards
Andy ( aka Large )
Posted: Sun Jun 29, 2003 6:46 pm
by Large
33 people viewed the topic, surely someone can help ! :roll:
Kind regards
Andy ( aka Large )
Posted: Sun Jun 29, 2003 6:54 pm
by Kale
This is not really a great way to do things because launching exe's from web pages is a big security risk. Prepare for your virus checker to go nuts when you do this.
http://developer.irt.org/script/1561.htm
BTW google.com is your friend!
Posted: Sun Jun 29, 2003 7:18 pm
by Large
Kale,
This is for a company intranet, ie: Internal so there will be no security risks, I want an active X component that can launch an exe, then I can put my intranet into trusted site security, so that I don't get any popups moaning about security risks, etc.
Thanks for the link as well but I have seen that and I have tried those examples, thats why I'm wondering if I can do it in PB ! :roll:
Kind regards
Andy ( aka Large )
Posted: Sun Jun 29, 2003 10:25 pm
by Num3
Check this code out!
Maybe you can adapt it for your needs:
http://freak.purearea.net/tools/IETool.zip
Re: creating an exe launcher !!!
Posted: Sun Jun 29, 2003 11:41 pm
by ricardo
@Large
I did one day what you are asking for in a very easy way: running some exe called by a link in a web page.
The IExplorer (and maybe the other ones too) first, when receive some click on a link or an order to navigate to some URL, checks the kind of software that will 'procces' that type of URL.
If the explorer find "HTTP://" the decides to do it by itself, if find FTP:// does something.
Then you need to register your own, something like 'MyOwn://' and tell the explorer the path of the application that will manage this kind of Url.
Then if your link si something like: "MyOwn://something" you application will run and receive the Url path as commandline, then just need to parse it and act.
In this case you application will receive "something" as the commandline.
As you can see, this is a very easy way to make that some links (or even redirections) runs something in a PC.
Of course, it will noly work IF the Explorer in that PC has register the application to be runned when some special PREFIX precedes the :// in the url.
Then you need to make your links or redirections just putting you prefix in the url.
I hope i make myself clear in the explanation.
Posted: Mon Jun 30, 2003 8:53 pm
by TerryHough
Andy, you should be able to adapt this code to your need. It does both
things that you discussed.
Just modify for the server address, username, and password and then run
the code. Look at the message returned and then modify the code to
interpret the message your POP3 server returns when there is or is not
messages available.
NOTE: The code below works with the popular InterMail POP3 server.
I've done others, you just have to see how they respond and adapt.
Some actually send you a count like the InterMail server and others just
send you a numbered list of message. In that case you just grab the
number of the last listed message. Hint: it usually preceeds the last
Chr(10) in the message I have found, but not guaranteed.
Code: Select all
;-----------------------------------------------------------------------
; POP3 - Check number of messages
; Written by TerryHough - last updated 06/30/2003
;-----------------------------------------------------------------------
eol$ = Chr(13)+Chr(10)
*Buffer = AllocateMemory(0, 5000)
If InitNetwork() = 0
MessageRequester("Error", "Can't initialize the network !", #MB_ICONSTOP)
End
Else
ConnectionID = OpenNetworkConnection("pop3.server.???", 110)
If ConnectionID
; most POP3 servers send an ID message back upon connection
; check if OK and respond with USER ID
Reply$ = ""
*Buffer = AllocateMemory(0, 5000)
RequestLength.l = ReceiveNetworkData(ConnectionID, *Buffer, 5000)
Reply$ = PeekS(*Buffer)
Result$ = Reply$
If Mid(Reply$,1,3) = "+OK"
; Send the USER ID now. Some POP3 servers don't prompt for it,
; but expect it to be sent here.
SendNetworkString(ConnectionID, "USER udername"+eol$)
Reply$ = ""
*Buffer = AllocateMemory(0, 5000)
; Should get back a password request if USER ID is valid
RequestLength.l = ReceiveNetworkData(ConnectionID, *Buffer, 5000)
Reply$ = PeekS(*Buffer)
Result$ = Result$ + Reply$
If Mid(Reply$,1,3) = "+OK"
Reply$ = ""
*Buffer = AllocateMemory(0, 5000)
; Send the PASSWORD now
SendNetworkString(ConnectionID, "PASS password"+eol$)
Reply$ = ""
*Buffer = AllocateMemory(0, 5000)
; Should get back a welcome message if password is accepted
RequestLength.l = ReceiveNetworkData(ConnectionID, *Buffer, 5000)
Reply$ = PeekS(*Buffer)
Result$ = Result$ + Reply$
If Mid(Reply$,1,3) = "+OK"
; Send the LIST command to get number of available messages
SendNetworkString(ConnectionID, "LIST"+eol$)
Reply$ = ""
*Buffer = AllocateMemory(0, 5000)
; Should get back the number of available messages or a list
; Interpret based on the response receive, they vary by server
; and may include info about the message ids
RequestLength.l = ReceiveNetworkData(ConnectionID, *Buffer, 5000)
Reply$ = PeekS(*Buffer)
Position = FindString(Reply$, "messages", 1)
If Position > 0
Result$ = Result$ + Reply$
messages = Val(Trim(Mid(Reply$, position -2 ,Len(Reply$))))
If messages > 0
UserWants = MessageRequester("Info",Result$ +Chr(10)+"You have " + Str(messages) + " messages."+Chr(10)+Chr(10)+"Do you wish to read your messages now?",#PB_MessageRequester_YesNo)
If UserWants = 6 ; pressed Yes button (Result = 6)
ProgResult = RunProgram("C:\Program Files\Outlook Express\msimn.exe", "", "\" , 1)
ElseIf UserWants = 7 ; pressed No button (Result = 7)
; Do nothing
EndIf
Else
MessageRequester("Info",Result$ +Chr(10)+"You have " + Str(messages) + " messages.",#MB_ICONINFORMATION)
EndIf
EndIf
Else
MessageRequester("Error","POP3 server didn't accept the PASSWORD.",#MB_ICONERROR)
EndIf
Else
MessageRequester("Error","POP3 server didn't accept the USER ID.",#MB_ICONERROR)
EndIf
EndIf
CloseNetworkConnection(ConnectionID)
Else
MessageRequester("Error","Unable to connect to POP3 server.",#MB_ICONERROR)
EndIf
EndIf
End
;-----------------------------------------------------------------------
; End of code for POP3 - Check number of messages
;-----------------------------------------------------------------------
Posted: Wed Jul 02, 2003 9:41 pm
by darklordz
Recardo was right you want to use the "URL Protocol". Use it to launch your pogram from a website. Do this by registering your program in the registry. Witch will make your app launch like thise Telnet:// What comes after the // will be seen as commandline. I created a download app for my site a while back. My links were beeing leeched and i created a downloader, this downloader was launched trough URL Protocol. Pretty neat...
Posted: Wed Jul 02, 2003 10:34 pm
by Kale
Then you need to register your own, something like 'MyOwn://' and tell the explorer the path of the application that will manage this kind of Url.
I'm interested to know how this is done?
Posted: Thu Jul 03, 2003 12:12 am
by ricardo
From Microsoft web:
To enable an application to handle a particular URL protocol, you must add a new key, with the appropriate keys and values, to the registry in HKEY_CLASSES_ROOT.
The new registry key must match the protocol scheme that is being added. For instance, to add the protocol note:, the key added to HKEY_CLASSES_ROOT should be note. Under this new key, the Default string value should be the name of the new protocol, and the URLProtocol string value should contain either protocol-specific information or an empty string. Also under the new key, a DefaultIcon key and a shell key should be added. The Default string value under the DefaultIcon key must be the file name to use as an icon for this new URL protocol. Under the shell key, a key using a verb (such as open) should be added. A command key and a DDEEXEC key can be added under the key using a verb. The values under the command and DDEEXEC keys are used to call the application.
The following example shows which registry values must be added to register a new application (notepad.exe in this example) to handle a new URL protocol (note:).
Code: Select all
[HKEY_CLASSES_ROOT]
[note]
(Default) = "URL:Note Protocol"
URL Protocol = ""
[DefaultIcon]
(Default) = "notepad.exe"
[shell]
[open]
[command]
(Default) = "c:\windows\notepad.exe %1"
By adding these settings to the registry, attempts to navigate to URLs such as note:c:\myfile.txt would launch Notepad to edit the file c:\myfile.txt. Of course, all the commands supported under Shell\Open are supported, including DDEEXEC (in other words, "command" is not the only key you can put under the verb).
http://msdn.microsoft.com/library/defau ... ndix_a.asp