Archive for the ‘Code’ Category

A property lost in tIME

March 25, 2014

The built-in PNG property handler does not support the tIME chunk for some reason. Why? I don’t know and it is only 7 bytes of data that is easy to parse!

We can fix this with a little shell extension. Sadly PSCreateMultiplexPropertyStore is documented to be read-only and I did not check if the system supplied version of IPropertyStore supports aggregation. We could hook the interface methods or do other tricks but just creating a simple wrapper seems to be enough to get a read-only version to work.

(more…)

I see your errorlevel and raise you a process exit code

December 7, 2012

Have you ever written a batch file that is more of a “application” than a script? Of course you made sure ERRORLEVEL is set correctly so when your batch file is a part of a larger script, IF ERRORLEVEL error checking can be used. What could go wrong?

For some crazy reason, cmd.exe does not use the expected logic when you use the && and/or || syntax. I assume part of the problem is because the batch file is executed by cmd.exe itself and there is no child process and no real process exit code.

Fixing this requires some hacky workarounds and is generally a big pain in the ass.
(more…)

Run, script, run!

March 1, 2011

You would think a scripting engine that has a separate console version (cscript.exe) would allow you to execute an external command/application and handle basic stdout output for you with a simple command, but sadly this is not the case. WScript.Shell’s Run method uses ShellExecute and unsurprisingly so does Shell.Application’s ShellExecute, that just leaves us with Exec.

This is what MSDN has to say about this method:

Runs an application in a child command-shell, providing access to the StdIn/StdOut/StdErr streams.

Sounds good right?
(more…)

(Safe) SHAutoComplete

May 29, 2010

For a long time, MSDN has stated that SHAutoComplete can only be called once on a HWND, but a recent blog post by Raymond Chen “documents” that this issue was fixed in Vista.

It sure would be nice to avoid the leak on older platforms as well, but MS is not going to help you (Implementing such a thing would reveal that their Subclassing API that supposedly is XP+ only actually goes all the way back to Win98 (Really IE5 on Win95 / NT4))

Without knowing the internals of browseui.dll (Where most of the autocomplete stuff seems to be implemented) we are left with a ugly hack: (more…)