URI launching a program from site and getting information from link - delphi

I have searched here for answers but I only seen few links to Microsoft c++ codes but none for Delphi so just wondering if anyone has a working Delphi example on how to launch programs from URI and get data from it to maybe connect to a socket or load a resource within my program?
Thanks
am basically looking for away to launch my program from a web address URI c++ code am none the wiser what to post as I can not understand that to save my life
and am sorry about not being more clear but I do find spelling things little hard and putting across what I would like I like to use voice mostly ha

You must register URI scheme for your application. For example, you may create "myapp" scheme. After this, if you open url like "myapp:do_something&close" Windows will launch your application with single parameter equal to URL.
"C:\program file\Soft\MyApplication.exe" "myapp:do_something&close"
In your application, you can read first parameter (ParamStr(1)), parse it and decide what to do.
"do_something&close" in my example, may be any kind of data. But if you want to open your application from web site, you may use HTTP URL format, like "myapp:\cleandisk?drive=C&askuser=yes"
See more info what you must write into Windows Registry in order to register your own URI scheme.

Related

What does this steam-desktop shortcut URL steam:// mean

How do steam-desktop shortcuts steam:// actually work?
The URL / target of them is something like: "steam://rungameid/717"
I know similar things like "ftp://mynetworkadress:1337/subfoldercontainsgoodstuff" or for sure "http://".
But why and how does this steam thing work, can you do something similar on your own (e.g. "niceapp://launchprocess/param") and if so, why would you?
steam:// is the Steam browser protocol, i.e. a proprietary URL handler.
The official documentation is at Valve Software.
An article by PCWorld on the Steam URL protocol and potential security threats can be found here:
When the Steam client is installed on a system, it registers itself as a steam:// URL protocol handler. This means that every time a user clicks on a steam:// URL in a browser or a different application, the URL is passed to the Steam client for execution.
But why and how does this steam thing work, can you do something similar on your own
Yes. You can implement anything on your own.
The URI format is basically:
<protocol>:<arguments>
Some protocols such as http and ftp accept URL as argument. However the argument for any arbitrary protocol does not have to be a URL. For example, the magnet: protocol used by Bittorrent does not use a URL instead it describes the torrent and the torrent hash.
As you have experienced, browsers support some protocols built in. This includes http and ftp as well as custom protocols such as about:config in Firefox and chrome://settings in Google Chrome to display the settings page.
If a browser encounters a protocol that it does not understand it will ask you what program you want to open the link with. It will then tell the OS to run that program and pass the argument as a command-line argument to that program. This is how you can get the browser to open steam: link in Steam or a magnet: link in a torrent client.
It used to be that you can type any protocol in the browser's URL bar and trigger this behavior. However, modern browsers also use the same input as a search bar so typing in protocol:argument manually these days will more likely trigger a Google search. But links still work as they used to.

Are friendly URLs based on directories?

I've been reading many articles about SEO and investigating how to improve my site. I found an article that said that having friendly URLs help online indexers to find and positionate your site better than using URLs with lots of GET parameters so I decided to adapt my site to this kind of URL. I've also read that there's a way (editing .htaccess) but it's not the best way and it doesn't look really good.
For example, that's how Google's About URL looks like:
https://www.google.com/search/about/es/
When surfing into FTP do they see the directories search/about/es/index.html? If so, you must create many files and directories for each language instead of using &l=es, is it that worth?
You can never know (for sure) how resources are mapped to URLs.
For example, the URL https://www.google.com/search/about/es/ could
point to the HTML file /search/about/es/index.html
point to the HTML file /foo/bar/1.html
point to the PHP script /index.php
point to the PHP script /search.php?title=about&lang=es
point to the document available from the URL https://internal.google.com/1238
…
It’s always the server that, given the URL from the request, decides which resource to deliver. Unless you have access to the server, you can’t know how. (Even if a URL ends with .php, it’s not necessarily the case that PHP is involved at all.)
The server could look for a file that physically exists (if URL rewriting is involved: even in "other" places than what the URL path suggests), the server could run a script that generates a document on the fly (e.g., taking the content from your database), the server could output the file available from another URL, etc.
Related Wikipedia articles:
Rewrite engine
Web framework: URL mapping
Front controller

Launching Electron app from a standard web browser

Clicking a mailto: link will open my default mail client. In a similar manner, I would like to launch an Electron app with my-app:. What is the best way to achieve this and gracefully fallback to a standard http link if the app isn't installed?
Furthermore, I would also like to be able to pass through some extra details my-app:foo/bar. How would this be intercepted inside of Electron when it launches?
I have read some docs on what I think might be relevant stuff: http://electron.atom.io/docs/v0.36.0/api/protocol/ however as a frontend dev there's some gaps in my understanding of how the overarching process works. Any help much appreciated!
Electron has evolved quite a bit since this question was first posted.
You no longer have to dive quite as deep and can skip the Electron protocol API. Instead, use the app.setAsDefaultProtocolClient(protocol[, path, args]) interface and its siblings app.removeAsDefaultProtocolClient(protocol[, path, args]) and app.isDefaultProtocolClient(protocol[, path, args]).
These enable you to register a protocol identifier your-protocol:// and receive arguments:
The whole link, including protocol, will be passed to your application
as a parameter. Electron API docs
I'm not sure if it is possible to do what you want to do. Depending on whether you want to launch your Electron app from an actual browser window or simply from another Electron instance.
I found this other Stack Overflow post link that shows a workaround (though I'm afraid it won't graciously default to anything) and explains how it could be dangerous to launch programs directly from the browser.
If you want to launch your Electron app from another Electron app however you might want to check this out link.

Best way to serve files?

I'm a novice web developer with some background in programming (mostly Python).
I'm looking for some basic advice on choosing the right technology.
I need to serve files over the internet (mp3's), but I need to implement some
control on the access:
1. Files will be accessible only for authorized users.
2. I need to keep track on how many times a file was loaded, by whom, etc.
What might be the best technology to implement this? That is, should I
learn Apache, or maybe Django? or maybe something else?
I'm looking for a 'pointer' in the right direction.
Thank!
R
If you need to track/control the downloads that suggests that the MP3 urls need to be routed through a Rails controller. Very doable. At that point you can run your checks, track your stats, and send the file back.
If it's a lot of MP3's, you would like to not have Rails do the actual sending of the MP3 data as it's a waste of it's time and ties up an instance. Look into xsendfile where Rails can send a response header indicating the file path to send and apache will intercept it and do the actual sending.
https://tn123.org/mod_xsendfile/
http://rack.rubyforge.org/doc/classes/Rack/Sendfile.html
You could use Django and Lighttpd as a web server. With Lighttpd you can use mod_secdownload, wich enables you to generate one time only urls.
More info can be found here: http://redmine.lighttpd.net/projects/1/wiki/Docs_ModSecDownload
You can check for permissions in your Django (or any other) app and then redirect the user to this disposable URL if he passed the permission check.

Block specified URLs

I want to write an application in Delphi which filters requested URLs in the OS (not only web browsers) and if it matches - blocks it or changes the URL's content to blank. The problem is - I don't know where to start looking. Could you help me with some informations?
I think you're talking about a DNS service. usually, DNS services live outside, on your router, your ISP, or a 3rd-party like www.openDNS.org
But you could write your own, run it on your PC, and set your internet settings to use that as your DNS server.
I suspect that a lot of malware works like this....
Also, this sort of thing can be done with no programming at all - just edit your hosts file in C:\WINDOWS\system32\drivers\etc\hosts (it's a text file with no extension).
Anything in there should trump.
Also, before you start writing an application to do this, have a look at OpenDNS. If it's an app for personal use, you may find that you don't need it. If it's going to be a commercial offering, this is the bar for usability and usefulness that you need to meet or beat.
http://www.mail-archive.com/delphi-talk#elists.org/msg01558.html - text by Francois PIETTE quoted bellow(in case link will become unavailable):
"There are several way to achieve your goal. The two main I see are:
1) Write a LSP (Layered Service Provider)
2) Write a proxy server
The first is not possible with Delphi (At least I think so. If anyone know
how to write a LSP using Delphi, I would love to get the code).
The second - writing a proxy - is more or less easy with Delphi using ICS
components. See "usermade" link at ICS website (http://www.overbyte.be).
With this option, you have to configure IE to use the proxy: IE Menu / Tools
/ Internet options / Connections / Network parameters / Use a proxy and then
enter the IP address (127.0.0.1 if proxy run on the same computer) and port
number (pick anyone you like, for example 8080). Once IE is configured to
use a proxy, it will send all requests to the proxy. Then the proxy will
make the real request to the target server and return data back to IE. What
is important there is that you get all URL entered in IE or indirectly use
(clicking on links), and you can either really rely them to the target
server or forge and answer your self to say the page access is denied.
At ICS website, on the usermade page, you'll even find a HTTP proxy
component. If you need help with this component and/or the entire ICS,
please use ICS support mailing list (same server as this list). See
"support" link at ICS website for support details."
LE: it seems that this question is possible a duplicate
Using delphi to block websites
use GetExtendedTcpTable api locate if there are any connexions to the remote server you want to block on port 80 if there is a connection use SetTcpEntry to terminate that connexion is pretty simple

Resources