RegisterShellEvent gets "no overloaded version" error

delphi package - easy access to shell apis
Post Reply
flightrisk
Posts: 6
Joined: Mon Feb 28, 2011 11:12 pm

RegisterShellEvent gets "no overloaded version" error

Post by flightrisk »

I'm getting "There is no overloaded version of "RegisterShellEvent" and UnRegisterShellEvent. " I am in Delphi XE and copied the code right out of the example code on the WEB. I tried just RegisterShellEvent(ShellEvent) with no parameters and that won't even work. I can't figure out what parameter doesn't match. Can anyone help?
flightrisk
Posts: 6
Joined: Mon Feb 28, 2011 11:12 pm

Re: RegisterShellEvent gets "no overloaded version" error

Post by flightrisk »

I'll answer my own question ;) It looks like the examples have not been updated along with the source. With Delphi 2009 and above, the base types for certain things like string and char were changed for UNICODE. So where before a char was mapped to an ansichar, it is now mapped to a widechar. So this line:

procedure ShellEvent(event: TShellEventType; const obj1, obj2: IShellObj; drive: char; value: cardinal);

Is incorrect since the soure type for ShellEvent has "drive" declared as an ansichar. This code will work in Delphi 2007 and below since char and ansichar are ths same. But in XE, where I live, char mapped to a widechar and broke the code. Change the drive: char to drive: ansichar.
madshi
Site Admin
Posts: 10339
Joined: Sun Mar 21, 2004 5:25 pm

Re: RegisterShellEvent gets "no overloaded version" error

Post by madshi »

You got it. I've chosen the "easy" way to make madCollection work with UNICODE Delphi versions: I've forced all strings and chars to stay ansi. I might implement proper UNICODE support in a future version.
flightrisk
Posts: 6
Joined: Mon Feb 28, 2011 11:12 pm

Re: RegisterShellEvent gets "no overloaded version" error

Post by flightrisk »

Great job on all the code by the way. I went through a painful conversion of a set of VCL and ActiveX controls that have over 100,000 lines of code. It was all API code with strings, pchars, pointers to C structures in memory and pointer math. I had to go over it line by line. What took me a while to figure this issue out was that the IDE pointed to the wrong parameter in a function and I had to "find declaration" all the way through each type and function until I worked through the chain. The error line pointed to the last parameter in the event function, not in the "register" and "unregister" functions where the problem actually was. So I focused on it probably being an unicode/XE issue and looked for each definition and compared anything that was a string or char to every other function.

On another note, did you used to do the folder watching with another API function? I have a control I found the source for and modified it slightly but it doesn't work in any pattern I can decipher. It uses SHChangeNotify and seems to behave differently if I copy a file to the folder or use a text editor to save the file to the folder or use my own test program to write a file to the folder. When I do the file write, it gets the folder change the first time, but then will not recognize any further deletes or new file creates if I use the same name. Very strange. I was going to change over to the ReadxxxW function when I found your great unit. Works better anyway, but I would still like to find out what is wrong with the other way. That control has individual event handlers for each messages like OnDirChange, OnItemChange, OnDirDelete, etc. I like individual event handlers for some reason, but realize that a case statement in one event handler is functionally the same. Again, great job.
madshi
Site Admin
Posts: 10339
Joined: Sun Mar 21, 2004 5:25 pm

Re: RegisterShellEvent gets "no overloaded version" error

Post by madshi »

It's a long time since I wrote madShell. I don't remember all the dirty details, but from what I have in mind SHChangeNotify wasn't really working so well. The ReadxxxW functions work much better, IIRC.
Post Reply