I have a registry entry e.g. LocalizedString=#%programfiles%\Internet Explorer\iexplore.exe,-702
Is there a known API to extract the path and the string other than custom-ally parse it (and use LoadString)?
And then I have a defult value e.g. (default)="%programfiles%\Internet Explorer\iexplore.exe" (including the double-quotes, but without the #);
How does Windows handle this stuff?
The API function you need is called RegLoadMUIStringW. This is a Vista API so if you want to support XP you'll need to parse the registry entry manually.
Update: Actually, SHLoadIndirectString looks like it could be your XP saviour.
Related
My Windows desktop application handles a specific URI scheme, let's call it myscheme:, so URLs like myscheme://what/ever open my app. We set that up by creating a registry key and several values under HKEY_CURRENT_USER\Software\Classes\myscheme. (It's an app that installs per-user without requiring elevation, thus the use of HKEY_CURRENT_USER.)
I would also like to be able to handle http: and https: URLs in a specified subdomain or path, such as http://mysubdomain.example.com/what/ever. Android provides a way to do this; can I do it in Windows?
I don't need a working example (I'm a fairly experienced Windows developer). All I'm looking for, if the capability exists, is a pointer to any relevant registry key or API name/docs on MSDN or elsewhere - I can take it from there. Thanks!
I've found a lot on this page on how to register a certain URI-scheme to open using a particular application in windows.
All Q & A which I've found cover creating an own protocol for this purpose which which is unique for the application which should be registered.
My question is: Is there a way to open usual http/https-Links which contain a certain pattern/format using application A, instead of opening all http/https-links with the browser?
Example: I want, that all links which match the format http://*.domainX.com/* or http://*.domainX.com/*, should be opened using my own application instead of the browser.
Thanks in advance!
On Windows you can try Registering the Application Handling the Custom URI Scheme
To register an application to handle a particular URI scheme, add a
new key, along with the appropriate subkeys and values, to
HKEY_CLASSES_ROOT. The root key must match the URI scheme that is
being added.
Let me know if this helps
I am trying to create my own URL protocol to initate a custom application from a URL in our internal CRM.
I have created the following registry entry as such:
REGEDIT4
[HKEY_CLASSES_ROOT\smon1]
#="URL:smon Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\smon1\shell]
[HKEY_CLASSES_ROOT\smon1\shell\open]
[HKEY_CLASSES_ROOT\smon1\shell\open\command]
#="\"C:\\smon.exe\" \"%1\""
I have the following link on my site:
<a href='smon:1955'>1955</a>
I would expect this to pass the variable 1955 to the aplication c:\smon.exe.
However it is passing the entire variable "smon:1955".
Why is it passing everything instead of the variable?
What am I missing here?
Your not missing anything, that's how the handlers work; the whole URI is passed in the command line. Detect and parse it away.
The rationale is presumably that it allows multiple protocols to be associated with the same executable without needing to provide custom discriminatory switches in the command key.
To give an example
An Example
this is passed to the browser and shown in the url bar as http://www.example.com
I used to be able to launch a locally installed helper application by registering a given mime-type in the Windows registry. This enabled me to allow users to be able to click once on a link to the current install of our internal browser application. This worked fine in Internet Explorer 5 (most of the time) and Firefox but now does not work in Internet Explorer 7.
The filename passed to my shell/open/command is not the full physical path to the downloaded install package. The path parameter I am handed by IE is
"C:\Document and Settings\chq-tomc\Local Settings\Temporary Internet Files\
EIPortal_DEV_2_0_5_4[1].expd"
This unfortunately does not resolve to the physical file when calling FileExists() or when attempting to create a TFileStream object.
The physical path is missing the Internet Explorer hidden caching sub-directory for Temporary Internet Files of "Content.IE5\ALBKHO3Q" whose absolute path would be expressed as
"C:\Document and Settings\chq-tomc\Local Settings\Temporary Internet Files\
Content.IE5\ALBKHO3Q\EIPortal_DEV_2_0_5_4[1].expd"
Yes, the sub-directories are randomly generated by IE and that should not be a concern so long as IE passes the full path to my helper application, which it unfortunately is not doing.
Installation of the mime helper application is not a concern. It is installed/updated by a global login script for all 10,000+ users worldwide. The mime helper is only invoked when the user clicks on an internal web page with a link to an installation of our Desktop browser application. That install is served back with a mime-type of "application/x-expeditors". The registration of the ".expd" / "application/x-expeditors" mime-type looks like this.
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\.expd]
#="ExpeditorsInstaller"
"Content Type"="application/x-expeditors"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller]
"EditFlags"=hex:00,00,01,00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller\shell\open]
#=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ExpeditorsInstaller\shell\open\command]
#="\"C:\\projects\\desktop2\\WebInstaller\\WebInstaller.exe\" \"%1\""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\MIME\Database\Content Type\application/x-expeditors]
"Extension"=".expd"
I had considered enumerating all of a user's IE cache entries but I would be concerned with how long it may take to examine them all or that I may end up finding an older cache entry before the current entry I am looking for. However, the bracketed filename suffix "[n]" may be the unique key.
I have tried wininet method GetUrlCacheEntryInfo but that requires the URL, not the virtual path handed over by IE.
My hope is that there is a Shell function that given a virtual path will hand back the physical path.
I believe the sub-directories created by IE are randomly generated, so you won't be able guarantee that it will be named the same every time, and the problem I see with the registry method is that it only works when the file is still in the cache...emptying the cache would purge the file requiring yet another installation.
Would it not be better to install this helper into application data?
I'm not sure about this but perhaps this may lead you in the right direction: try using URL cache functions from the wininet DLL: FindFirstUrlCacheEntry, FindNextUrlCacheEntry, FindCloseUrlCache for enumeration and when you locate an entry whose local file name matches the given path maybe you can use RetrieveUrlCacheEntryFile to retrieve the file.
I am using a similar system with the X-Appl browser to display WAML web applications and it works perfectly. Maybe you should have a look at how they managed to do it.
It looks like iexplore is passing the shell namespace "name" of the file rather than the filesystem name.
I dont think there is a documented way to be passed a shell item id on the command line - explorer does it to itself, but there are marshaling considerations as shell item ids are (pointers to) binary data structures that are only valid in a single process.
What I might try doing is:
1. Call SHGetDesktopFolder which will return the root IShellFolder object of the shell namespace.
2. Call the IShellFolder::ParseDisplayName to turn the name you are given back into a shell item id list.
3. Try the IShellFolder::GetDisplayNameOF with the SHGDN_FORPARSING flag - which, frankly, feels like w'eve just gone in a complete circle and are back where we started. Because I think its this API thats ultimately responsible for returning the "wrong" filesystem relative path.
Some follow-up to close out this question.
Turned out the real issue was how I was creating the file handle using TFileStream. I changed to open with fmOpenRead or fmShareDenyWrite which solved what turned out to be a file locking issue.
srcFile := TFileStream.Create(physicalFilename, fmOpenRead or fmShareDenyWrite);
Is there any Win32/MFC API to get the CSIDL_LOCAL_APPDATA for any user that I want (not only the currently logged on one)? Let's say I have a list of users in the form "domain\user" and I want to get a list of their paths - is that possible?
You can get the SID for the user and then look it up under HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList and get the ProfileImagePath value.
Once you have this path, you can get CLSID_LOCAL_APPDATA for your user, convert the absolute path to a relative path to your profile and then append that relative path to the other user profile path.
However, keep in mind that this is relying on an undocumented registry key and can break in future versions of the OS. (Or, as Raymond Chan would say: "Now that you know how to do it, let me tell you why you shouldn't do it this way..." :-))
If you have a token representing the user, you can use the SHGetFolderPath or SHGetKnownFolderPath (on Vista and up). However, there are certain security restrictions and you should read up on MSDN for details.
SHGetFolderPath - http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx
SHGetKnownFolderPath - http://msdn.microsoft.com/en-us/library/bb762188(VS.85).aspx