blog: riddles in programming
Moderators: fgagnon, nikos, Site Mods
blog: riddles in programming
here's the comment area for today's blog entry found at:
http://www.zabkat.com/blog/08Jul07.htm
http://www.zabkat.com/blog/08Jul07.htm
Straightforward, once you found enough of the puzzle pieces ---
even clever in spots. But, it's too bad that it took so much work slogging through the m$ morass to cobble together a solution.
So, I say, Good work, Sherlock!
(Yet, as satisfying as that was, I am sure you would have preferred to find a more elegant solution.)
even clever in spots. But, it's too bad that it took so much work slogging through the m$ morass to cobble together a solution.
So, I say, Good work, Sherlock!
(Yet, as satisfying as that was, I am sure you would have preferred to find a more elegant solution.)
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
Hi nikos,
I have been struggling with this a bit. I actually was overriding the IShellFolder and returning my own IDataObject last year but I was missing the registry key piece of it. I have it all working... sort of. Are you 100% successful now? My problem is that when I call release on the Context menu that CDefFolderMenu_Create2 give me if I have too many keys in the key list it crashes RegCloseKey from within the release call of the IContextMenu object. I have not yet closed the keys before doing this so it is not from double closing them. I can't quite tell you exactly where the issue is. If it is greater then 5 or 7 registry key or if it is after 500 files with > 5 keys. I can get to a point where if I add just one more file to the list it will crash and if I remove that file from the list it will succeed.
Just wondering if you were having any strange issues such as this.
Jim Kueneman
P.S. It is not that my IShellFolder wrapper is being prematurely released I have checked all my reference counted objects during this and non of them are being freed before during or after the crash on the ContextMenu release occurs.
I have been struggling with this a bit. I actually was overriding the IShellFolder and returning my own IDataObject last year but I was missing the registry key piece of it. I have it all working... sort of. Are you 100% successful now? My problem is that when I call release on the Context menu that CDefFolderMenu_Create2 give me if I have too many keys in the key list it crashes RegCloseKey from within the release call of the IContextMenu object. I have not yet closed the keys before doing this so it is not from double closing them. I can't quite tell you exactly where the issue is. If it is greater then 5 or 7 registry key or if it is after 500 files with > 5 keys. I can get to a point where if I add just one more file to the list it will crash and if I remove that file from the list it will succeed.
Just wondering if you were having any strange issues such as this.
Jim Kueneman
P.S. It is not that my IShellFolder wrapper is being prematurely released I have checked all my reference counted objects during this and non of them are being freed before during or after the crash on the ContextMenu release occurs.
Hi Jim,
Welcome to the board!
nikos is on vacation until the end of August.
(He may only check in at random until then.)
Your query sounds like it is a program development issue, rather than xplorer2-related.
Although you might get a constructive reply from nikos or our readers, you are likely to get more help sooner from the users at The Code Project: http://www.codeproject.com/
-fg-
Welcome to the board!
nikos is on vacation until the end of August.
(He may only check in at random until then.)
Your query sounds like it is a program development issue, rather than xplorer2-related.
Although you might get a constructive reply from nikos or our readers, you are likely to get more help sooner from the users at The Code Project: http://www.codeproject.com/
-fg-
Last edited by fgagnon on 2007 Aug 13, 13:08, edited 1 time in total.
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
Yup it is.Your query sounds like it is a program development issue, rather than xplorer2-related.
Has nikos implemented the context menus for the scrap container and has it be working fine?Although you might get a constructive reply from nikos or our readers, you are likely to get more help sooner from the the users at The Code Project: http://www.codeproject.com/
Jim
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
Hey Nikos,
Looks like Xplorer2 has the same problems I am having. It does weird things in Win2k if you have too many different kinds of file types and will crash. I am thinking the right thing to do is only put the file type of the currently focused node and then special types like "*", "AllSystemsFiles", etc.
I will keep you posted.
Jim
Looks like Xplorer2 has the same problems I am having. It does weird things in Win2k if you have too many different kinds of file types and will crash. I am thinking the right thing to do is only put the file type of the currently focused node and then special types like "*", "AllSystemsFiles", etc.
I will keep you posted.
Jim
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
Wish I knew you were so close to me, we could have talked shell over a beer (ok a few hundred miles). I almost have it working in all versions of Windows. The only thing I would like to understand is the Copy/Cut menu items. I had to override GetAttribuitesOf as well and test if each item was SHAGO_CANMOVE/CANCOPY as with fully qualified PIDLs the desktop IShellFolder fails. Did you have to do this?
Also it looks like win2k and 9x need either HKCR/Directory OR HKCR/Folder and not both when using a folder as the "focused" item in a list. I am only running the registry on the extension of the item the use clicked over and that fixes the duplicate menu items and crashes I had and also see in xplorer2 on Win2k and 9x.
The keys I am using on the focused item are:
For Files:
HKCR\*
HKCR\AllFIleSystemObjects
HKCR\{.ext}
HKCR\\{FileClass} (pointed to by default string of above, also checked for CurVer string)
HKCR\FileSystemAssociations\{.ext}
reading HKCR\{.ext}\PerceivedType and opening
HKCR\FileSystemAssociations\{PerceivedType}
if the extension is not found then using
HKCR\Unknown
For Directories:
HKCR\Folder
HKCR\Directory
Again this does not work right for Win2k and 9x, it seems to double up the "Main" verbs (Open, Explorer, Print, etc) I will let you know what do do for those OS's when I get some time to figure it out.
Jim
Also it looks like win2k and 9x need either HKCR/Directory OR HKCR/Folder and not both when using a folder as the "focused" item in a list. I am only running the registry on the extension of the item the use clicked over and that fixes the duplicate menu items and crashes I had and also see in xplorer2 on Win2k and 9x.
The keys I am using on the focused item are:
For Files:
HKCR\*
HKCR\AllFIleSystemObjects
HKCR\{.ext}
HKCR\\{FileClass} (pointed to by default string of above, also checked for CurVer string)
HKCR\FileSystemAssociations\{.ext}
reading HKCR\{.ext}\PerceivedType and opening
HKCR\FileSystemAssociations\{PerceivedType}
if the extension is not found then using
HKCR\Unknown
For Directories:
HKCR\Folder
HKCR\Directory
Again this does not work right for Win2k and 9x, it seems to double up the "Main" verbs (Open, Explorer, Print, etc) I will let you know what do do for those OS's when I get some time to figure it out.
Jim
haven't tried on win2K recently, but for XP i just tried a context menu on 2500 files (various) and both the menu and the execution of commands was pronto
perhaps for w2000 there are the same problems as with multi file properties, and this patch may be useful:
http://support.microsoft.com/default.as ... s%3B330040
finally i don't use these keys at all:
HKCR\FileSystemAssociations\{.ext}
HKCR\FileSystemAssociations\{PerceivedType}
hth
nikos
ps
why don't you come to this year's ESWC ?
perhaps for w2000 there are the same problems as with multi file properties, and this patch may be useful:
http://support.microsoft.com/default.as ... s%3B330040
finally i don't use these keys at all:
HKCR\FileSystemAssociations\{.ext}
HKCR\FileSystemAssociations\{PerceivedType}
hth
nikos
ps
you're in belgium right, the best beer in the worldWish I knew you were so close to me, we could have talked shell over a beer
why don't you come to this year's ESWC ?
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
Here is what it looks like on Win2k
http://www.mustangpeak.net/2xplorer.bmp
Jim
http://www.mustangpeak.net/2xplorer.bmp
Yes it work on Vista and XP (though I did get it to crash and vanish on XP).haven't tried on win2K recently, but for XP i just tried a context menu on 2500 files (various) and both the menu and the execution of commands was pronto
It does not "feel" like that is the problem.perhaps for w2000 there are the same problems as with multi file properties, and this patch may be useful:
http://support.microsoft.com/default.as ... s%3B330040
Then how do you get the "Print" menu item? That was the only way I could get it. I use RegMon to look at what the Explorer Search window was opening and it uses these keys.finally i don't use these keys at all:
HKCR\FileSystemAssociations\{.ext}
HKCR\FileSystemAssociations\{PerceivedType}
Nope that is Cyber (http://www.cubicreality.com). I live in Arizona.you're in belgium right, the best beer in the world Smile
why don't you come to this year's ESWC ?
Jim
i managed to crash it on 2000 and more worryingly on vista for huge file collections
how many files did you have selected in that x2 snapshot you sent with the gazillion open/print menu commands?
how many files did you have selected in that x2 snapshot you sent with the gazillion open/print menu commands?
then we lost the opportunity for beer last week when i was crossing arizona (driving from las vegas to jackson hole). Nice rugged country!I live in Arizona
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
My experience as well.i managed to crash it on 2000 and more worryingly on vista for huge file collections
You can see in the shot. Less than a dozen.how many files did you have selected in that x2 snapshot you sent with the gazillion open/print menu commands?
Can you share how you are loading the PHKEY structure, with what keys? I have it work 100% now on all version of windows (did not try NT or 95). No crashes and no duplicate items.
Jim
-
- Member
- Posts: 13
- Joined: 2007 Aug 13, 04:40
I don't know. I do know that somehow we are doing something different as I said I could not get the "Print" item until I used this:so how did you stop crashes and duplicates?
HKCR\FileSystemAssociations\{.ext}
HKCR\FileSystemAssociations\{PerceivedType}
In a nut shell this is what I am doing:
Load and array with the AbsolutePIDLs for all selected items then prepare what keys to load:
Code: Select all
procedure TCommonShellMultiParentContextMenu.LoadRegistryKeyStrings(Focused: TNamespace);
begin
KeyStrings.Clear;
Extensions := [cmeShellDefault, cmeAsterik, cmeAllFilesystemObjects, cmeFileSystemAssociations];
// Only add the menu handlers for the focused item class
if Assigned(Focused) then
begin
if Focused.Folder then
Extensions := [cmeShellDefault, cmeFolder]
else
AddMenuKey(WideExtractFileExt(Focused.NameForParsing));
end
end;
Now when I show the menu I do this:
Code: Select all
if cmeDirectory in Extensions then
AddMenuKey('Directory');
if cmeDirBackground in Extensions then
AddMenuKey('Directory\Background');
if cmeFolder in Extensions then
AddMenuKey('Folder');
if cmeAsterik in Extensions then
AddMenuKey('*');
if cmeAllFilesystemObjects in Extensions then
AddMenuKey('AllFilesystemObjects');
1) the extension of the "Focused" node
2) '*'
3) 'AllFilesystemObjects'
IF the Focused item was a file ELSE it contains
1) 'Folder'
What cmeShellDefault does is cause DFM_MERGECONTEXTMENU to return S_OK in the callback
Now with the reg key list all loaded I start drilling into the hive.
Code: Select all
UnknownAdded := False;
Reg := TTntRegistry.Create;
try
Reg.Access := KEY_READ;
Reg.RootKey := HKEY_CLASSES_ROOT;
for i := 0 to KeyStrings.Count - 1 do
begin
if (KeyStrings[i] <> '') then
begin
if Reg.OpenKey(KeyStrings[i], False) then
begin
// The extension key is open {.ext}
AddKey(DuplicateKey(Reg.CurrentKey), Keys);
WS := Reg.ReadString('');
Reg.CloseKey;
if WS <> '' then
begin
if Reg.OpenKey(WS, False) then
begin
// The FileClass is open, see if there is mulitiple version and a current version
if Reg.KeyExists('CurVer') then
begin
if Reg.OpenKey('CurVer', False) then
begin
CurVer := Reg.ReadString('');
if Reg.OpenKey('\' + CurVer, False) then
AddKey(DuplicateKey(Reg.CurrentKey), Keys);
end;
Reg.CloseKey;
end else
begin
AddKey(DuplicateKey(Reg.CurrentKey), Keys);
Reg.CloseKey;
end
end
end
end else
begin
if not UnknownAdded and Reg.OpenKey('Unknown', False) then
begin
AddKey(DuplicateKey(Reg.CurrentKey), Keys);
Reg.CloseKey;
UnknownAdded := True
end
end;
if cmeFileSystemAssociations in Extensions then
begin
if Reg.OpenKey('SystemFileAssociations\' + KeyStrings[i], False) then
begin
AddKey(DuplicateKey(Reg.CurrentKey), Keys);
Reg.CloseKey;
end
end;
if cmePerceivedType in Extensions then
begin
if Reg.OpenKey(KeyStrings[i], False) then
begin
WS := Reg.ReadString('PerceivedType');
if WS <> '' then
begin
if Reg.OpenKey('\SystemFileAssociations\' + WS, False) then
AddKey(DuplicateKey(Reg.CurrentKey), Keys);
end;
Reg.CloseKey;
end
end
end
end
finally
Reg.CloseKey;
Reg.Free
end;
I think that is self explanatory if not let me know. The main thing is searching for the right file class through the CurVal key and if the extension is not found using the "Unknown" key. What I just noticed is I now have the "Print" item but I am not defining cmePerceivedType so that key is not being used..... I don't know now. I have tried and experimented so much over the last few weeks I am getting myself confused :oops:
Anyway the way I show seems to be working.
Jim