I am looking for a Windows API that I can call from Delphi 2010 which will allow my application to determine if a specific folder has content-indexing enabled. In other words whether there is a tick in the checkbox named 'Allow files in this folder to have contents indexed in addition to file properties' which is in the Advanced Attributes page of the Property dialog when you right-click the folder. I cannot find much about this on MSDN, but maybe I am not looking in the right places.
function IsFolderIndexed(const folderName: string): boolean;
begin
Result := (GetFileAttributes(folderName) AND $2000) = 0;
end;
Ref: http://msdn.microsoft.com/en-us/library/ee332330(VS.85).aspx
Related
Question
when you right-click on the desktop (or folder, file, etc) the context menu entries that appear are either statically generated or dynamically generated via a loaded DLL that implements specific interfaces. read more about the differences between static entries and dynamic ones here.
I just bought a new computer and decided to fully customize my windows context menu.
Basically, this question asks about complete control over your windows context menus, even the dynamic ones, and even the built-in ones(if possible).
The static entries are easy to manage and can be easily managed via the registry or a tool.
the dynamically generated entries are the problem because it's hard to understand which of the loaded DLLs caused a certain entry label to apear.
For example: context menu on certain file types(like .txt) will load an entry "Move to OneDrive". how do I find the DLL that loaded that sentence?
so to summer up, how do i:
get from the context menu entry label(eg 'Move to OneDrive') the path of the ContextMenuHandlers DLL that loaded it. Alternatively, finding out the ContextMenuHandler that generated this entry.
✅ disable its loading. (can be done by editing the UID to something else,for example prefixing with '-')
some values are restored after reboot, how do I cancel that?
('Move to OneDrive' is a true and annoying example but I asking about any entry, even the 'Rename' or 'Properties')
Possible directions:
Using Sysinternals process explorer we can search a handle or a loaded DLL, however, how can you tell in a DLL generated a specific string(eg 'Move to OneDrive')?
Example:
for documentation purposes, not actual part of the question
Following this example we can understand,
The registry entries that are responsible for the dynamic entries on the directory context menu are listed in Computer\HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers
let's take the EPP Key for example:
we can see that the value of the EPP key is {09A47860-11B0-4DA5-AFA5-26D86198A780}
following this example:
HKEY_CLASSES_ROOT
.myp
(Default) = MyProgram.1
CLSID
{00000000-1111-2222-3333-444444444444}
InProcServer32
(Default) = C:\MyDir\MyCommand.dll
ThreadingModel = Apartment
{11111111-2222-3333-4444-555555555555}
InProcServer32
(Default) = C:\MyDir\MyPropSheet.dll
ThreadingModel = Apartment
MyProgram.1
(Default) = MyProgram Application
Shellex
ContextMenuHandler
MyCommand
(Default) = {00000000-1111-2222-3333-444444444444}
PropertySheetHandlers
MyPropSheet
(Default) = {11111111-2222-3333-4444-555555555555}
using our value for the EPP entry {09A47860-11B0-4DA5-AFA5-26D86198A780}, we can understand that the DLL that loaded this entry is listed here Computer\HKEY_CLASSES_ROOT\CLSID\{09A47860-11B0-4DA5-AFA5-26D86198A780}\InprocServer32, and in this case the value of this entry is C:\Program Files\Windows Defender\shellext.dll
We can 'Windows Defender' in the path, so we can assume it's responsible for loading the context entry with the label 'Scan with windows defender'
However, seems that that story does not end here, after disabling all static and dynamic entries for context directory there are still entries in the context menu. how do I revel which DLL loaded them?
I use Delphi Rio (Windows Desktop App) and need to display in a TWebBrowser some webpages.
I ran into a problem with this WooCommerce site, https://merletdance.com/eshop.
When I ask for this one, I can't pass the cookies dialog. I understand it's in relation with JScript and/or JQuery, but is there a way to bypass or better (some parameters of TwebBrowser) ?
[Edit] Works with Delphi 11 (Alexandria) using Edge
Found a solution, even if for my users with heterogeneous park it's not a cure-all: Embarcadero's documentation on TWebBrowser hints to edit the registry:
Supporting JavaScript Integration on Windows Platform
On Windows target platforms (WIN32 and WIN64), TWebBrowser may incorrectly display some Web pages if a Web site uses JavaScript dialog boxes, panels, and other elements for various purposes.
To work around this issue, your application should display Web pages in the IE11 edge mode using the FEATURE_BROWSER_EMULATION feature of Internet Explorer.
Open the Registry Editor.
Open the following key: HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION
On the Edit menu, point to New, and then click DWORD (32-bit) Value.
Set the name of this new entry to your executable file name, such as MyApps.exe.
Select the newly created entry, and on the Edit menu, click Modify.
In the Edit dialog box that opens, do the following:
In the Value data text box, enter 11011
Under Base, select Decimal
Click OK to save your changes
You can also cause your application to make the above described changes when the application starts. For example, in your project, the FormCreate event handler can call the following TForm1.SetPermissions method:
procedure TForm1.FormCreate(Sender: TObject);
begin
{$IFDEF MSWINDOWS}
SetPermissions;
{$ENDIF}
end;
{$IFDEF MSWINDOWS}
procedure TForm1.SetPermissions;
const
cHomePath = 'SOFTWARE';
cFeatureBrowserEmulation =
'Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\';
cIE11 = 11001;
var
Reg: TRegIniFile;
sKey: string;
begin
sKey := ExtractFileName(ParamStr(0));
Reg := TRegIniFile.Create(cHomePath);
try
if Reg.OpenKey(cFeatureBrowserEmulation, True) and
not(TRegistry(Reg).KeyExists(sKey) and (TRegistry(Reg).ReadInteger(sKey)
= cIE11)) then
TRegistry(Reg).WriteInteger(sKey, cIE11);
finally
Reg.Free;
end;
end;
{$ENDIF}
Note: You should make these appropriate changes to the registry before starting the application. After you start your application for the first time, close it, and then start again.
In Delphi XE7, I want to use the following code to replace the link target of a shell link file (.lnk):
uses
JclShell;
...
procedure ShellLinkReplaceLinkTarget(const AShellLinkFile, ANewTarget: string);
var
ThisShellLink: JclShell.TShellLink;
begin
if (JclShell.ShellLinkResolve(AShellLinkFile, ThisShellLink) = S_OK) then // Windows error dialog
begin
ThisShellLink.Target := ANewTarget;
JclShell.ShellLinkCreate(ThisShellLink, AShellLinkFile);
end
else CodeSite.Send('ShellLinkResolve Failed!');
end;
However, when the link target does not exist anymore, then at ShellLinkResolve the well known Link problem Windows error dialog comes up telling that the link target has been deleted etc. Here is the dialog in German:
So how can I suppress this dialog? Because the program needs to replace the missing link target with another one, not Windows.
Windows 7 x64 SP1
EDIT:
BTW: When I click on the Restore button (the leftmost button in the above dialog screenshot), then the missing target is restored from the waste basket - but the dialog is NOT being closed after the successful restore or at least the Restore button disabled after the restore. An example of bad UI design by Microsoft.
Try the following code:
if (JclShell.ShellLinkResolve(AShellLinkFile, ThisShellLink,
SLR_ANY_MATCH or SLR_NO_UI) = S_OK) then
I'm creating a custom file format for use by my application based on the OPC (or maybe the XPS) file format. This MSDN link, Using System-Supplied Property Handlers, gives an example but it doesn't appear to be correct. Does anybody know how to do this properly?
Edit:
This can apply to OPC files as well as XPS. XPS is build on top of OPC.
You have to:
Create a key named with your extension (e.g. a key named .doc) under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PropertySystem\PropertyHandlers.
Then set the default value for the key you just created to {45670FA8-ED97-4F44-BC93-305082590BFB}
Under Root/SystemFileAssociations add a key named with your file extension (e.g. .doc).
Under that key add "shellex\PropertyHandler"
Set default value under the PropertyHandler key to {45670FA8-ED97-4F44-BC93-305082590BFB}.
Now you have to tell Windows what properties to display depending on circumstance.
Add FullDetails, PreviewDetails, ExtendedTileInfo, and InfoTip keys to the Root/SystemFileAssociations/ key.
This property handler is good for both OPC (open package conventions) and XPS files.
PreviewDetails is the property pane at the bottom of windows explorer (Win 7) or the left hand side of explorer (Win 8).
FullDetails is the properties you see when you right click and select properties and go to the Details tab.
InfoTip is the properties you see when you hover over a file.
ExtendedTileInfo I'm not sure about. I think it's the properties you see when you select the content folder view in explorer.
{45670FA8-ED97-4F44-BC93-305082590BFB} is the GUID for the OPC/XPS property handler given in the MSDN link in my question.
OPC is basically a standard for creating a (zipped) file type. Can see more here: MSDN Magazine - Aug. 2007 OPC - A New Standard For Packaging Your Data.
I only tested in Windows 7 but it should work in Vista and above. I'll post back after I do further testing.
Friends,
In testing our Oracle Forms application on Vista I have found a interesting "challenge".
The application can invoke the Microsoft Word spell checker to perform a spell check on a field. When invoked, the user is shown the standard Microsoft Word spell checker dialog window. Word itself is invisble to the user.
The Spell Checker is invoked from Forms using Automation and the method used is based on the metalink note: 295449.1 How To Integrate The MS Word Spell Checker With Forms Using WebUtil.
This has worked well when invoked using Windows XP and Office 2003.
However when this same (unchanged) functionality is run on Vista, the Microsoft Word Spell Checker dialog window appears behind the browser window so to the user it appears that nothing has happened and the functionality isn't working(There is no indication on the Vista taskbar that spell checker has been invoked)
The problem occurs on Vista with Office 2007 and Office 2003. I can see that the problem is caused by Vista because if I use the same url used to launch the Forms application on WindowsXP, the Microsoft Word Spell Checker dialog window appears as expected, which is in front.
Within Vista I have tried setting the compatability mode for Office to Windows XP SP2 but the problem remains.
I have also tried explicitly setting ACTIVATE (as you can see from the sample code below) but without success.
Has anyone else run in to this? Any help or pointers to where others have experienced this problem would be gratefully received!
My environment details are:
Environment Details
Oracle Forms: 10.1.2.3
JRE: Sun JRE 1.6.0_14
Database: 10.2.0.3
Vista: Business Edition with Service Pack 1
Office: 2003 or 2007
The code (which needs to go in a client side Oracle) used to invoke the spell checker is:
PROCEDURE SPELL_CHECK (ITEM_NAME IN VARCHAR2) IS
MY_APPLICATION CLIENT_OLE2.OBJ_TYPE;
MY_DOCUMENTS CLIENT_OLE2.OBJ_TYPE;
MY_DOCUMENT CLIENT_OLE2.OBJ_TYPE;
MY_SELECTION CLIENT_OLE2.OBJ_TYPE;
GET_SPELL CLIENT_OLE2.OBJ_TYPE;
MY_SPELL CLIENT_OLE2.OBJ_TYPE;
ARGS CLIENT_OLE2.LIST_TYPE;
SPELL_CHECKED VARCHAR2(4000);
ORIG_TEXT VARCHAR2(4000);
BEGIN
ORIG_TEXT := ITEM_NAME;
-- CREATE WORD.APPLICATION OBJECT
MY_APPLICATION := CLIENT_OLE2.CREATE_OBJ('WORD.APPLICATION');
--CLIENT_OLE2.SET_PROPERTY(MY_APPLICATION, 'VISIBLE', FALSE);
CLIENT_OLE2.SET_PROPERTY(MY_APPLICATION, 'VISIBLE', TRUE);
--CLIENT_OLE2.INVOKE(MY_APPLICATION, 'ACTIVATE');
-- GET HANDLE FOR DOCUMENTS COLLECTION
MY_DOCUMENTS := CLIENT_OLE2.GET_OBJ_PROPERTY(MY_APPLICATION, 'DOCUMENTS');
-- ADD A NEW DOCUMENT TO THE DOCUMENTS COLLECTION
MY_DOCUMENT := CLIENT_OLE2.INVOKE_OBJ(MY_DOCUMENTS, 'ADD');
-- GET HANDLE FOR SELECTION OBJECT
MY_SELECTION := CLIENT_OLE2.GET_OBJ_PROPERTY(MY_APPLICATION, 'SELECTION');
-- INSERT THE TEXT FIELD INTO DOCUMENT
CLIENT_OLE2.SET_PROPERTY(MY_SELECTION, 'TEXT', ORIG_TEXT);
-- GET HANDLE FOR ACTIVE DOCUMENT
GET_SPELL := CLIENT_OLE2.GET_OBJ_PROPERTY(MY_APPLICATION, 'ACTIVEDOCUMENT');
-- INVOKE SPELL CHECKER
CLIENT_OLE2.INVOKE(GET_SPELL, 'CHECKSPELLING');
CLIENT_OLE2.INVOKE(MY_APPLICATION, 'ACTIVATE');
-- Added to handle a cancel request.
CLIENT_OLE2.INVOKE(MY_SELECTION,'WholeStory');
CLIENT_OLE2.INVOKE(MY_SELECTION,'Copy');
-- GET CHECKED TEXT FROM DOCUMENT
SPELL_CHECKED := CLIENT_OLE2.GET_CHAR_PROPERTY(MY_SELECTION, 'TEXT');
-- REFORMAT RETURN TEXT TO DISPLAY CORRECTLY IN FORMS
SPELL_CHECKED := substr(replace(SPELL_CHECKED,chr(13),chr(10)), 1, length(SPELL_CHECKED));
-- COPY NEW TEXT IN THE FORM
COPY(SPELL_CHECKED,ITEM_NAME);
-- CLOSE THE DOCUMENT WITHOUT SAVING
ARGS := CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(ARGS, 0);
CLIENT_OLE2.INVOKE(MY_DOCUMENT, 'CLOSE',ARGS);
CLIENT_OLE2.DESTROY_ARGLIST(ARGS);
-- RELEASE THE OLE OBJECTS
CLIENT_OLE2.RELEASE_OBJ(MY_SELECTION);
CLIENT_OLE2.RELEASE_OBJ(GET_SPELL);
CLIENT_OLE2.RELEASE_OBJ(MY_DOCUMENT);
CLIENT_OLE2.RELEASE_OBJ(MY_DOCUMENTS);
CLIENT_OLE2.INVOKE(MY_APPLICATION, 'QUIT');
CLIENT_OLE2.RELEASE_OBJ(MY_APPLICATION);
END;
EDIT: 10/08/2009
This link http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23085081.html details the same problem (but this time instead of oracle forms controlling word, it's ms access) Unfortunately I can't see the answer(if there is one that is!)
EDIT: 12/08/2009
All the link to expert-exchange states is that this is a vista problem - like I didn't know that!
Looks like this can't be solved using Automation\OLE alone, this thread notes there is a problem with the activate method within OLE\Automation and Vista.
The way round it is to call the windows api to manipulate the windows.