|
(Originally posted: 2008-02-01)
These are the steps for setting up COM+ debugging in Windows 2000. Note that there are known issues with this and it may not work correctly, even if you follow all the steps. It is even more unlikely that it will work correctly under Windows XP.
Setting up COM+
In AdmistrativeTools -> Component Services :
. Ensure that the COM dlls registered in Component Services point to the dlls that the Delphi project will create when it compiles. Usually, this means deleting the original COM applications in Component Services, and readding the DLLs that are generated by the Delphi project compilation.
. Right click on the COM Application you are debugging (not the COM object itself), and go to Properties->Identify and ensure that 'Interactive User - the current logged on user' is selected. If you don't see the Identity tab, you may be trying to access the properties of the COM object instead of the COM application it resides in.
. Get the Application identifier for the COM object itself: Right click on the COM object and go to Properties. Under CLSID is the Application ID (a GUID). Copy this as it will be used later when setting up the Delphi Project.
Setting up the Delphi Project
In the Delphi Project you wish to debug:
. Go to Project->Options
Under the 'Linker' tab, ensure that the options 'Include TD32 debug info' and 'Include remote debug symbols' are checked.
Click OK.
. Go to Run->Parameters .
Under 'Host Application' find 'dllhost.exe' in the WINNT\system32 folder.
Under 'Parameters', paste the Application identifier you got from earlier (see Setting up COM+). Entering in '/ProcessID:{GUID}', where GUID is the Application identifier, may work better.
Click OK.
The application should now be set up to debug. Set the breakpoints you want the debugger to stop at, and click Run. If all goes well, the project will be shown in run mode and will wait for the break point to hit.
Troubleshooting
If your break points are not being hit:
. It is recommended that dllhost.exe is copied to the directory where the COM+ dll file is and it is referred to in Delphi 'Host Application' step above. This is a required step on a Windows XP machine.
. You may need to set the Include remote debug symbols option under Project | Options | Linker. Make sure to shutdown the COM+ application that contains the DLL first. This can be done fom the Component Services Admin utility.
. Change the COM+ application settings to Activation -> Library and use Shift+F7 to step into the com+ code
. The pathfilename of the dll containing the COM is not in 8.3 format. There are 2 solutions:
1: Put de DLL in a directory in 8.3 format like C:\Test\MyCom.dll and NOT C:\My Test\My Com.dll
2: Put your DLL anywhere, register it, search the registration key with RegEdit and change the pathfilename in the registry by the long pathfilename format like C:\My Test\My Com.dll
Resources
. CodeGear from Borland[^]
. Debugging COM+ services written in Delphi 7 (D7)[^]
. Why can't I get breakpoints to work when debugging a COM+ or MTS app in Delphi?[^]
. On Windows XP, it is very difficult to set breakpoints in a COM, Delphi do not stops[^]
|
|
|
|
|
(Originally posted: 2007-10-11)
Check the EventViewer Application log:
. Go to Start -> Control Panel -> Administrative Tools -> Event Viewer
. Look for Error with Source: COM+ and Event ID: 4786.
|
|
|
|
|
(originally posted: 2007-10-12)
There are many representations of text in C++. Usage and conversion should be done with great care...
. (Visual C++) How to: Convert Between Various String Types[^]
This article only touches on the issue of CURRENCY data type.
CURRENCY is implemented as an 8-byte two's-complement integer value scaled by 10,000. This gives a fixed-point number with 15 digits to the left of the decimal point and 4 digits to the right. The CURRENCY data type is very useful for calculations involving money, or for any fixed-point calculations where accuracy is important.
Here is the code used in Mercury.cpp of VivoClientApi.dll that converts CURRENCY to text and vice versa for the purposes of the Mercury project (text is used loosely )
CURRENCY2Text:
CURRENCY Currency_Amount;
CString Currency_Text = "";
Currency_Text.Format("%.2f", (float)(Currency_Amount.int64) / 10000);
Text2CURRENCY (reading from an XML doc):
CURRENCY Currency_Amount;
COleCurrency COleCurr_Amount;
MSXML::IXMLDOMNodePtr pNode;
pNode = pDOMDoc->selectSingleNode("//Amount/Authorize");
if(pNode)
{
COleCurr_Amount.ParseCurrency(W2T(pNode->Gettext()));
Currency_Amount = COleCurr_Amount.m_cur;
}
See Also:
. MFC Simple Data Types[^]
. MFC COleCurrency[^]
. ATL CComCurrency[^]
. Component Automation: CURRENCY[^]
|
|
|
|
|
(Originally posted: 2007-09-20)
The call to Application.ProcessMessages requires the inclusion of Forms unit.
If the size of the dll is of a concern, consider replacing the call with:
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
For more details: http://www.delphipages.com/forum/showthread.php?t=181620[^]
Here is the Application.ProcessMessage() extracted from the Forms.pas:
function TApplication.ProcessMessage(var Msg: TMsg): Boolean;
var
Handled: Boolean;
begin
Result := False;
if PeekMessage(Msg, 0, 0, 0, PM_REMOVE) then
begin
Result := True;
if Msg.Message <> WM_QUIT then
begin
Handled := False;
if Assigned(FOnMessage) then FOnMessage(Msg, Handled);
if not IsHintMsg(Msg) and not Handled and not IsMDIMsg(Msg) and
not IsKeyMsg(Msg) and not IsDlgMsg(Msg) then
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end
else
FTerminate := True;
end;
end;
Note: This function requires Windows.pas and Messages.pas.
|
|
|
|