Thoughts from Dan Miser RSS 2.0
 Monday, November 01, 2004
While I was thinking about how best to provide a write-up on getting COM Interop working with my pluggable COM architecture, I came across this Delphi 8 paper and this Delphi 2005 paper by Brian Long (of Falafel) in one of his blog entries. It's rather complete from a Delphi perspective, so all that I would need to cover would be how to link a Delphi Win32 COM host with a VS.NET C# client. Somehow, I don't think that's nearly as exciting, since Brian did such an excellent job detailing COM Interop.

Hopefully this will give me a chance to talk about my custom COM audting/profiling solution instead.

Edited on 11/2/04 to update the links based on feedback from Brian Long. Thanks, Brian!

Monday, November 01, 2004 1:12:00 PM (Central Standard Time, UTC-06:00)  #    Comments [0] -
Delphi
 Wednesday, October 27, 2004
This is not YAGDSP (Yet Another Google Desktop Search Post). Well, not completely. ;-)

I like Google Desktop Search. It's lightning fast, and I like the idea and implementation. I think it will really get better once they release an API. For some reason, I never really latched on to IndexServer. I'm not sure why, it just seems too cumbersome or something. I like the concept of IndexServer, but I always end up using grep instead. Maybe it's just that Old Habits Die Hard.

But with GDS, I find myself using it more for some reason. However, as a Delphi or C# developer, you probably aren't deriving much benefit from this version of the GDS beta since pas and cs files are not indexed. Lord CRC (sorry, don't know his actual name) solved that problem by hacking the EXE to change the file extensions that are indexed. He also puts in some information on what you can do to fix this yourself if you're uncomfortable with using his hacked EXE. You can download the hack here.

Wednesday, October 27, 2004 11:07:00 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
Delphi
 Tuesday, October 26, 2004
Great. I've read about spamming in blog comments from some of the blogging luminaries. I've had a couple of spams so far, and I could deal with that. But, this morning I had 12 spams that I had to go delete. I guess I could spin this into some kind of positive that it means that someone actually thinks my blog is worth spamming, but I'm not going to go that far. :-)

So, if anyone has any links on how to effectively deal with blog comment spam (especially with .Text), I'm all ears. I don't want to turn off comments because I enjoy reading the responses. Thanks for any help.

Tuesday, October 26, 2004 8:42:00 AM (Central Standard Time, UTC-06:00)  #    Comments [3] -

 Monday, October 25, 2004
I love it when things just work the way they should. I've been developing a new product that relies heavily on a pluggable architecture using COM. During development, I started thinking that it would be nice to test out how well a C# component would work inside the architecture. As you can tell from the first line of this entry, it worked rather well. I plan on detailing a write-up of the details, but the short story is: it just works.

It's always refreshing to find technology that makes your life easier, instead of making the waters muddy and more difficult.

Monday, October 25, 2004 8:23:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -
.NET
 Wednesday, October 20, 2004
We have several DataSnap (ugh, it still pains me to say that instead of MIDAS :-)) servers in our application suite. We can run them either as regular processes or services. Recently, one of our customers went to Windows 2003 and our applications quit working. It turns out that Microsoft made some changes in Win2003 that causes a "Server Execution Failed" error when running a COM server as a service.

While searching Google, I found one post from Anders Evensen, who had contacted Microsoft directly about the issue. According to him, "The problem is that Microsoft requires StartServiceCtrlDispatcher to be called before CoRegisterClassObject. However, this requirement has not been implemented in earlier versions of Windows than 2003. Windows 2003 checks that the service has been started before it allows CoRegisterClassObject to be called."

Delphi does this backwards, since StartServiceCtrlDispatcher is called in TService.Execute, and CoRegisterClassObject is called during the call to Application.Initialize. I ended up with the following solution, and things now work wonderfully on all Windows versions.


function IsRunningInInstallMode : Boolean;

  function FindSwitch(const Switch: string): Boolean;
  begin
    Result := FindCmdLineSwitch(Switch, ['-', '/'], True);
  end;

begin
  Result := FindSwitch('REGSERVER') or FindSwitch('UNREGSERVER')
    or FindSwitch('INSTALL') or FindSwitch('UNINSTALL');
end;

procedure TService1.ServiceExecute(Sender: TService);
begin
  { Windows 2003 Server support. The problem is that you should always call
    StartServiceCtrlDispatcher (done in VCL) before calling CoRegisterClassObject
    (done from Application.Initialize). Win2003 now enforces this explicitly, but
    earlier versions did nothing if this was done improperly. }
  if not IsRunningInInstallMode then
    SvcMgr.Application.Initialize;

  while not Terminated do
  begin
    ServiceThread.ProcessRequests(false);
    Sleep(500);
  end;
end;
Wednesday, October 20, 2004 3:51:00 PM (Central Standard Time, UTC-06:00)  #    Comments [3] -
Delphi
 Tuesday, October 19, 2004
Well, there's more there than just DataSnap stuff, but the DataSnap info coming out of this blog is top shelf.
Ondrej Kelle's Blog
DataSnap.NET
DataSnap Perfomance Counter Libraries writeup
DataSnap Performance Counter Libraries download

Keep up the good work, Ondrej!

Tuesday, October 19, 2004 8:08:00 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -
DataSnap
 Monday, October 18, 2004
I installed AD/AM (download link is here) a while back in order to do some LDAP testing on my local XP box without having to turn it into a full-fledged Domain Controller. It installs easily and works reasonably well.

However, I was having all sorts of problems getting the WinLDAP JEDI port to work against AD/AM. AD/AM is LDAP version 3, so I modified the demo that came with JEDI to say:


  Version := LDAP_VERSION3;
  ldap_set_option(nil, LDAP_OPT_PROTOCOL_VERSION, @Version);

The result of all of this is that I get an "Operations error" when calling ldap_search_s. Doing some digging on Google, I believe there is some problem with the authentication against AD/AM when using ldap_simple_bind_s. No error is returned, but my gut tells me the error lies there.

My first thought at solving this was to create a hook DLL that would do OutputDebugStrings each and every time I used the wldap32.dll. Doing this, I could compare the calls and parameters used when using the Address Book (wab.exe) program - which works - and the sample program from the JEDI port - which doesn't work. I even used ldp.exe to do some testing and couldn't get authentication and searching to work properly. ldp reported that my ldap_simple_bind_s authenticated me properly, but the subsequent call to ldap_search_s resulted in the Operations Error with extended server error information telling me that "In order to perform this operation a successful bind must be completed on the connection.".

In the end, I had to succumb to deadline pressures. I now use ADSI, and things work just fine. I'd really like to get the low-level LDAP working, but that has to be a task left for another day.

Monday, October 18, 2004 9:17:00 AM (Central Standard Time, UTC-06:00)  #    Comments [0] -

 Friday, October 15, 2004
If you've ever developed an ActiveForm, then you probably have run into the scenario where you go to a standard control in your form (e.g. an Edit control), select the text, and then press Ctrl+C to copy the text. However, I'm willing to bet that your next reaction was stunned amazement when you realized that the text was not actually copied to the clipboard. To make matters even more maddening, if you use Ctrl+X or Ctrl+V in that very same edit control, things work as you would expect.

I had to fix this problem recently, and it is awfully strange. Pressing Ctrl+X and Ctrl+V makes the TActiveFormControl.TranslateAccelerator method return S_FALSE. Pressing Ctrl+C, the return is S_OK. So in order to fix this, I want to return S_FALSE when Ctrl+C is pressed. I do this by creating a new TActiveXControlClass that overrides the TranslateAccelerator method and returns S_FALSE when needed. The only other thing that needs to be done is to use the new class in your TActiveFormFactory.Create call so that we can get calls to our TranslateAccelerator method and do our own custom stuff.

One caveat: Things are working quite well in IE6. I'm not sure what will happen in other ActiveX containers. Use at your own risk, or at least test in whatever container you're deploying to first!

Here's the code. Please let me know what you think. If you see any improvements that can be made, I'd love to hear about those, too. But at least, for now, my customers are happy again.


type
 TTranslateAcceleratorFormControl = class(TActiveFormControl, IOleInPlaceActiveObject)
  function TranslateAccelerator(var msg: TMsg): HResult; stdcall;
 end;

{ TTranslateAcceleratorFormControl }
{ 
When pressing Ctrl+C, the inherited method returns S_OK meaning that the container thinks
it did what it needed to, and therefore, the message is consumed. When pressing Ctrl+X or
Ctrl+V, the return from the inherited method is S_FALSE.

Therefore, we will always call the inherited method to allow for default processing. If the
return is S_OK, and the message is WM_KEYDOWN, and we have pressed Ctrl+C, we override
the result and return S_FALSE instead.
}
function TTranslateAcceleratorFormControl.TranslateAccelerator(var msg: TMsg): HResult;
begin
  Result := inherited TranslateAccelerator(msg);

  if Result = S_OK then  
  begin
    if (msg.message = WM_KEYDOWN) and (GetKeyState(VK_CONTROL) < 0) and (msg.wParam = 67) then
      Result := S_FALSE;
  end;
end;

initialization
  TActiveFormFactory.Create(
    ComServer,
    //TActiveFormControl,             // standard Delphi-generated class
    TTranslateAcceleratorFormControl, // our replacement class
    TAFActionTest,
    Class_AFActionTest,
    1,
    '',
    OLEMISC_SIMPLEFRAME or OLEMISC_ACTSLIKELABEL,
    tmApartment);
end.
Friday, October 15, 2004 12:56:00 PM (Central Standard Time, UTC-06:00)  #    Comments [1] -
Delphi
Falafel has assembled a team whose excellence is hard to surpass. Now they're putting on a conference. The line up of speakers and cost makes me wonder how it's possible, but who am I to question it. :-)

I hope everyone doesn't rush out there and sign up right away and shut me out of a spot. I'm trying to work some things out so that I can get there.

Friday, October 15, 2004 8:26:00 AM (Central Standard Time, UTC-06:00)  #    Comments [1] -

Navigation
Archive
<November 2004>
SunMonTueWedThuFriSat
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2008
Dan Miser
Sign In
Statistics
Total Posts: 310
This Year: 25
This Month: 1
This Week: 0
Comments: 605
All Content © 2008, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)