delphi-2009

Delphi interface inheritance: Why can't I access ancestor interface's members?

爷,独闯天下 提交于 2019-11-26 21:48:39
问题 Assume you have the following: //Note the original example I posted didn't reproduce the problem so //I created an clean example type IParent = interface(IInterface) ['{85A340FA-D5E5-4F37-ABDD-A75A7B3B494C}'] procedure DoSomething; end; IChild = interface(IParent) ['{15927C56-8CDA-4122-8ECB-920948027015}'] procedure DoSomethingElse; end; TGrandParent = class(TInterfacedObject) end; TParent = class(TGrandParent) end; TChild = class(TParent, IChild) private FChildDelegate: IChild; public

How to recompile a specific unit from the VCL?

不羁的心 提交于 2019-11-26 21:36:09
问题 I want to apply a fix from QC to a Delphi 2009 unit (DBClient as it happens). I know I need to copy the unit to another directory and make the change to the copy. How do I then get Delphi to compile that unit and use it in favour of the DCU that already exists? 回答1: If you don't want to modify the original .Pas file, I do this by copy the .Pas file into my application folder, then choose built project, it will create new dcu file in my application folder, which will be used instead of the

How to achieve smaller size of the executable?

寵の児 提交于 2019-11-26 20:00:48
问题 Very recently I have come back to Delphi after a long pause and written a rather straightforward utility app my client requested to support an older release... I know these days the size does not matter much, but it struck me as odd that the one-unit application, when compiled, amounted to 1'084'416 b executable. The one and only .pas unit I wrote is some 20.8k large, mostly because of the richness of the gui. The uses clause is as follows: uses Windows, Messages, SysUtils, Variants, Classes,

Which variables are initialized when in Delphi?

北城以北 提交于 2019-11-26 17:24:46
So I always heard that class fields (heap based) were initialized, but stack based variables were not. I also heard that record members (also being stack based) were also not initialized. The compiler warns that local variables are not initialized ([DCC Warning] W1036 Variable 'x' might not have been initialized), but does not warn for record members. So I decided to run a test. I always get 0 from Integers and false from Booleans for all record members. I tried turning various compiler options (debugging, optimizations, etc.) on and off, but there was no difference. All my record members are

Delphi Enterprise: how can I apply the Visitor Pattern without circular references?

南楼画角 提交于 2019-11-26 16:48:04
问题 With Delphi 2009 Enterprise I created code for the GoF Visitor Pattern in the model view, and separated the code in two units: one for the domain model classes, one for the visitor (because I might need other units for different visitor implementations, everything in one unit? 'Big ball of mud' ahead!). unit VisitorUnit; interface uses ConcreteElementUnit; type IVisitor = interface; IElement = interface procedure Accept(AVisitor :IVisitor); end; IVisitor = interface procedure

Faster DirectoryExists function?

孤人 提交于 2019-11-26 16:44:00
问题 I use DirectoryExists (const PathName : String); to check if a directory is reachable from a computer or not. But if the directory does not exist and the path name is a network path, i.e. \\computer1\Data the method takes a very long time to return. There must be a faster way to determine that a network folder is not reachable. Or can I configure some timeout parameter that DirectoryExists uses internally (I looked at the source code but it just delegates to GetFileAttributes which is defined

What are major incentives to upgrade to D2009 (Unicode excluded)?

£可爱£侵袭症+ 提交于 2019-11-26 16:32:21
问题 I'm a hesitant upgrader when it comes to development tools. For roughly half of my product I still use D7, and for others D2006. The truth is, although Unicode support is more than welcomed and very useful, it could cause me more troubles than gains with my current projects (they are more-or-less Unicode ready already). It's especially case with one of them who's performance would suffer a lot if each string takes twice as much memory as before. So, Unicode aside, what are other major

Why does ReadDirectoryChangesW omit events?

醉酒当歌 提交于 2019-11-26 15:53:19
问题 I use ReadDirectoryChangesW to watch a specified directory and update indexing structures whenever a change is detected. I use the following code (roughly) var InfoPointer : PFileNotifyInformation; NextOffset : DWORD; ... while (not Terminated) do begin if ReadDirectoryChangesW (FDirHandle, FBuffer, FBufferLength, True, FFilter, @BytesRead, @FOverlap, nil) then begin WaitResult := WaitForMultipleObjects (2, @FEventArray, False, INFINITE); if (WaitResult = waitFileChange) then begin

How to cast a Interface to a Object in Delphi

自古美人都是妖i 提交于 2019-11-26 14:29:11
问题 In delphi 2009 I have a reference to a IInterface which I want to cast to the underlying TObject Using TObject(IInterface) obviously doesn't work in Delphi 2009 (it's supposed to work in Delphi 2010 though) My searches lead me to a function that should do the trick, but it doesn't work for me, I get AV's when I try to call methods on the returned object. I can't really modify the Classes and I know that this breaks OOP 回答1: Instead of relying on Delphi's internal object layout you could also

Delphi 2009: How to communicate between Windows service & desktop application under Vista?

心已入冬 提交于 2019-11-26 13:55:03
问题 How can a desktop application communicate with a Windows service under Vista/Windows2008/Windows7? The application needs to send small strings to the service and receive string responses back. Both are written in Delphi 2009. (Please provide sample code also) 回答1: The way to go is named pipes, you'll probably have to take a look at the communication across different Integrity levels. This article explores how to do this in vista. Although it's written in c++ it's just basic Windows API calls,