Wednesday, January 25, 2006

AtlReportError

Why havn't I've seen this before?!?

Say you you have received an socket-error:


int socketErr = HOST_NOT_FOUND;
HRESULT hr = MAKE_HRESULT(1, FACILITY_INTERNET, socketErr);
TCHAR *errMsg; // Fill using FormatMessage
hr = AtlReportError(GetObjectCLSID(), errMsg, GUID_NULL, hr);
//Free errMsg
return hr;

An now, when _com_error or VB-Err object are examined, we get textual
messages that make sense!

Icons in VB 6

I just found that for VB to add an icon at design-time it has to be a
.ico-file containing a single icon, 8bit.

Tuesday, January 24, 2006

ThreadEntryPoint in Java (1.4.x)

I needed a ThreadEntryPoint in a Java project.
Since I failed to find a existing implementation of this tool, I wrote one myself.
Do you know if I missed a better implementation? Tell me!


ThreadEntryPoint
The idea is that we have several small tasks that can be executed by several concurrent threads. The threads are normally a part of a threadpool.
Sometimes a subset of these tasks should be performed in a certain order, one at a time. An example could be when you controll several telephones; if you issue a "lift-hook" to the telephony subsystem no other calls should be performed at the same time. It is usually much simpler to write the code when you know that no other task will change member variables in the Telephone object.

ThreadEntryPointHandler.java
The external API is:


public class ThreadEntryPointHandler
{
public void PostMsg(Object entryPointID, Runnable task);
}


When you issue a task with a new entrypoint ID a new entrypoint is created and the execution starts. If you would add another task while the first is running the second is placed in the entrypoints internal queue. When the queue is empty the entrypoint removes itself (to save threads in the system).

The problems encountered when implementing is making sure that creating and destroying entrypoints without problems due to concurrency. I simply solved this by synchronizing on the handler a little more then really needed, and thereby avoiding the philosophers problem.

Monday, January 16, 2006

HTTP XML Request with self-signed certificate

I have a webservice at https://foo/ws . I wish to access this using MSXL2.XMLHttpRequest.
It seems to work out-of-the-box if the certificate is trusted fully.

However, if it is a self-signed certificate, it seems like a no-can-do. Still googling this...

InstallShield, add/remove properties

I tried to find where details of where Windows Installer store the Support Info shown in Add/remove programs. (Here is what Expresso shows.)

After some searching I found that it is stored in several places, but RegMon did show me the truth. SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\InstallShield_{4E6FC601-093D-4DDF-ACC8-63C27F9FDB7D}
(Where, ofcourse, the product code varies with the product.)

When I did a "dirty" upgrade of a product I simply changed DisplayVersion to "6.5.0200" and Version to DWORD:0x06050200 and everything looked peechy.