Skip to content

Commit 5cf78ac

Browse files
committedMay 19, 2019
Dll in Delphi: Aggiunta gestione della quantità
1 parent 05a1429 commit 5cf78ac

File tree

5 files changed

+44
-18
lines changed

5 files changed

+44
-18
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ __history/
22
Win32/
33
*.skincfg
44
bin/
5+
TestDllPas/TestDllPas.identcache

‎TestDllPas/ImplItfCppOrdine.pas

+28-11
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,20 @@ TImplCppRiga = class(TObject, ICppRiga)
2525
public
2626
function GetCodice: PWideChar; stdcall;
2727
function GetDescrizione: PWideChar; stdcall;
28+
function GetQta(): Integer; stdcall;
2829
protected
2930
// Property per i test
3031
m_cod: AnsiString;
3132
m_des: AnsiString;
33+
m_qta: Integer;
3234

3335
m_refCount: Integer;
3436
constructor Create(const codice: AnsiString; const descrizione: AnsiString);
37+
function generaQta(): Integer;
3538
function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;
3639
function _AddRef: Integer; stdcall;
3740
function _Release: Integer; stdcall;
41+
3842
end;
3943

4044

@@ -45,27 +49,28 @@ TImplCppRiga = class(TObject, ICppRiga)
4549
@Date: 28/04/2019
4650
----------------------------------------------------------------* }
4751

48-
4952
TImplCppOrdine = class(TObject, ICppOrdine)
5053
public
51-
5254
m_cppRiga: TImplCppRiga;
5355

54-
constructor Create();
55-
destructor Destroy(); override;
5656
function GetNumeroOrdine: Integer; stdcall;
5757
function GetRiga(const index: Integer): { ICppRiga } Pointer; stdcall;
5858
function ContaRighe(): Integer; stdcall;
59+
60+
constructor Create();
61+
destructor Destroy(); override;
5962
protected
6063
// Property private di mockup per i test
6164
m_numeroOrdine: Integer;
6265
m_lstRighe: TList;
6366

6467
m_refCount: Integer;
6568
procedure creaDatiMockup();
69+
6670
function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;
6771
function _AddRef: Integer; stdcall;
6872
function _Release: Integer; stdcall;
73+
6974
end;
7075

7176
implementation
@@ -121,15 +126,14 @@ function TImplCppOrdine.GetNumeroOrdine: Integer;
121126

122127
function TImplCppOrdine.GetRiga(const index: Integer): { ICppRiga } Pointer;
123128
var
124-
kk: Integer;
129+
rg: TImplCppRiga;
125130
begin
126-
if index > m_lstRighe.Count then
127-
result := nil
128-
else
131+
result := nil;
132+
if index <= m_lstRighe.Count then
129133
begin
130-
// scorro alla ricerca della riga richiesta
131-
for kk := 0 to index do
132-
result := m_cppRiga;
134+
// ritorno la struttura cercata
135+
rg := m_lstRighe.Items[index];
136+
result := Pointer(ICppRiga(rg));
133137
end;
134138
end;
135139

@@ -163,6 +167,14 @@ constructor TImplCppRiga.Create(const codice, descrizione: AnsiString);
163167
begin
164168
m_cod := codice;
165169
m_des := descrizione;
170+
m_qta := generaQta();
171+
end;
172+
173+
function TImplCppRiga.generaQta: Integer;
174+
begin
175+
result := Random(5);
176+
if result = 0 then
177+
result := 1;
166178
end;
167179

168180
function TImplCppRiga.GetCodice: PWideChar;
@@ -181,6 +193,11 @@ function TImplCppRiga.GetDescrizione: PWideChar;
181193
result := buff;
182194
end;
183195

196+
function TImplCppRiga.GetQta: Integer;
197+
begin
198+
result := m_qta;
199+
end;
200+
184201
function TImplCppRiga.QueryInterface(const IID: TGUID; out Obj): HRESULT;
185202
begin
186203
Pointer(Obj) := self;

‎TestDllPas/ItfCppOrdine.pas

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface
1313
ICppRiga = interface
1414
function GetCodice(): PWideChar; stdcall;
1515
function GetDescrizione(): PWideChar; stdcall;
16+
function GetQta(): Integer; stdcall;
1617
end;
1718

1819

‎TestDllPas/TestDllPas.dproj

+14-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<FrameworkType>None</FrameworkType>
66
<MainSource>TestDllPas.dpr</MainSource>
77
<Base>True</Base>
8-
<Config Condition="'$(Config)'==''">Debug</Config>
8+
<Config Condition="'$(Config)'==''">Release</Config>
99
<Platform Condition="'$(Platform)'==''">Win32</Platform>
1010
<TargetedPlatforms>1</TargetedPlatforms>
1111
<AppType>Library</AppType>
@@ -44,15 +44,22 @@
4444
<CfgParent>Base</CfgParent>
4545
<Base>true</Base>
4646
</PropertyGroup>
47+
<PropertyGroup Condition="('$(Platform)'=='Win32' and '$(Cfg_2)'=='true') or '$(Cfg_2_Win32)'!=''">
48+
<Cfg_2_Win32>true</Cfg_2_Win32>
49+
<CfgParent>Cfg_2</CfgParent>
50+
<Cfg_2>true</Cfg_2>
51+
<Base>true</Base>
52+
</PropertyGroup>
4753
<PropertyGroup Condition="'$(Base)'!=''">
54+
<DCC_Alignment>0</DCC_Alignment>
4855
<Manifest_File>None</Manifest_File>
4956
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
5057
<DCC_Namespace>System;Xml;Data;Datasnap;Web;Soap;$(DCC_Namespace)</DCC_Namespace>
5158
<GenDll>true</GenDll>
5259
<VerInfo_Locale>1040</VerInfo_Locale>
5360
<SanitizedProjectName>TestDllPas</SanitizedProjectName>
5461
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
55-
<DCC_ExeOutput>.\$(Platform)\$(Config)</DCC_ExeOutput>
62+
<DCC_ExeOutput>..\TestAppCpp\bin</DCC_ExeOutput>
5663
<DCC_E>false</DCC_E>
5764
<DCC_N>false</DCC_N>
5865
<DCC_S>false</DCC_S>
@@ -63,10 +70,10 @@
6370
<DCC_UsePackage>FireDACPgDriver;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;DbxCommonDriver;dbxcds;CustomIPTransport;dsnap;IndyIPServer;IndyCore;CloudService;FmxTeeUI;FireDACIBDriver;dsnapxml;FireDACDb2Driver;bindcompfmx;FireDACODBCDriver;RESTBackendComponents;dbrtl;FireDACCommon;bindcomp;inetdb;xmlrtl;FireDACCommonDriver;bindengine;soaprtl;FMXTee;FireDACMSSQLDriver;DBXInformixDriver;DataSnapServerMidas;DBXFirebirdDriver;inet;FireDACMySQLDriver;soapmidas;DBXSybaseASADriver;RESTComponents;dbexpress;IndyIPClient;FireDACSqliteDriver;FireDACDSDriver;DBXSqliteDriver;fmx;IndySystem;tethering;DataSnapClient;DataSnapProviderClient;fmxFireDAC;DBXOracleDriver;fmxase;IndyIPCommon;DataSnapFireDAC;FireDACDBXDriver;soapserver;inetdbxpress;FireDACInfxDriver;FireDACASADriver;rtl;DbxClientDriver;DataSnapNativeClient;IndyProtocols;DBXMySQLDriver;bindcompdbx;FireDACADSDriver;FireDAC;fmxobj;FireDACOracleDriver;fmxdae;FireDACMSAccDriver;DataSnapIndy10ServerTransport;$(DCC_UsePackage)</DCC_UsePackage>
6471
</PropertyGroup>
6572
<PropertyGroup Condition="'$(Base_Win32)'!=''">
73+
<Debugger_HostApplication>D:\Temp\EsempiXE\CppCallDelphi\TestAppCpp\bin\TestAppCpp.exe</Debugger_HostApplication>
6674
<DCC_UsePackage>cxSchedulerTreeBrowserRS20;dxPSdxPDFViewerLnkRS20;dxSkinOffice2007SilverRS20;cxGridRS20;dxFireDACServerModeRS20;dxPSdxLCLnkRS20;dxPScxExtCommonRS20;cxPageControlRS20;dxPSdxSpreadSheetLnkRS20;FireDACPgDriver;dxPSdxMapControlLnkRS20;dxSkinVisualStudio2013DarkRS20;DBXInterBaseDriver;DataSnapServer;DataSnapCommon;dxSkinsdxBarPainterRS20;dxSkinSharpRS20;DbxCommonDriver;dxLayoutControlRS20;vclimg;dxSkinSilverRS20;dxSkinsdxNavBarPainterRS20;dbxcds;DatasnapConnectorsFreePascal;dxPSCoreRS20;dxSkinOffice2013LightGrayRS20;vcldb;dxPSTeeChartRS20;dxSkinOffice2013WhiteRS20;dxSkinMcSkinRS20;CustomIPTransport;dsnap;IndyIPServer;dxSkinCoffeeRS20;dxSkinGlassOceansRS20;IndyCore;dxSkinOffice2010SilverRS20;dxComnRS20;CloudService;dxSkinOffice2013DarkGrayRS20;dxFlowChartRS20;FmxTeeUI;FireDACIBDriver;dxDBXServerModeRS20;FMXfrx20;BCEditor.Delphi.XE6.Runtime;dxSkinOffice2007PinkRS20;dxSkinSpringTimeRS20;dxOfficeCoreRS20;dxSkinVisualStudio2013BlueRS20;dxSkiniMaginaryRS20;cxTreeListdxBarPopupMenuRS20;dxPScxGridLnkRS20;dxSkinDevExpressDarkStyleRS20;dxPsPrVwAdvRS20;cxSchedulerGridRS20;dxtrmdRS20;dsnapxml;dxSpreadSheetRS20;FireDACDb2Driver;dxSkinMoneyTwinsRS20;dxSkinOffice2007GreenRS20;dxPScxTLLnkRS20;dxRichEditControlRS20;cxPivotGridOLAPRS20;dxPSdxFCLnkRS20;dxPSdxGaugeControlLnkRS20;bindcompfmx;dxPDFViewerRS20;vcldbx;dxSpreadSheetConditionalFormattingDialogsRS20;FireDACODBCDriver;RESTBackendComponents;dbrtl;FireDACCommon;bindcomp;inetdb;FMXfrxDB20;dxSkinVisualStudio2013LightRS20;DBXOdbcDriver;vclFireDAC;xmlrtl;dxSkinOffice2007BlackRS20;FireDACCommonDriver;bindengine;vclactnband;soaprtl;FMXTee;dxGDIPlusRS20;bindcompvcl;vclie;dxPSRichEditControlLnkRS20;cxVerticalGridRS20;cxSchedulerRS20;dxRibbonCustomizationFormRS20;dxSkinBlackRS20;FireDACMSSQLDriver;DBXInformixDriver;dxSkinSummer2008RS20;Intraweb;DataSnapServerMidas;dsnapcon;DBXFirebirdDriver;inet;dxBarRS20;cxDataRS20;dxSkinDarkSideRS20;FireDACMySQLDriver;soapmidas;vclx;dxPScxVGridLnkRS20;dxSkinLondonLiquidSkyRS20;dxCoreRS20;DBXSybaseASADriver;RESTComponents;dxPSPrVwRibbonRS20;dbexpress;dxPSLnksRS20;IndyIPClient;dxSpellCheckerRS20;dxBarExtItemsRS20;dxdbtrRS20;FireDACSqliteDriver;FireDACDSDriver;cxSchedulerRibbonStyleEventEditorRS20;DBXSqliteDriver;fmx;dxSkinVS2010RS20;dxPScxPCProdRS20;IndySystem;dxSkinXmas2008BlueRS20;TeeDB;tethering;inetdbbde;dxTabbedMDIRS20;DataSnapClient;dxmdsRS20;DataSnapProviderClient;DBXSybaseASEDriver;dxdborRS20;dxPSdxDBTVLnkRS20;MetropolisUILiveTile;dxSkinCaramelRS20;dxPScxSchedulerLnkRS20;dxSkinLiquidSkyRS20;dxSkinOffice2016DarkRS20;vcldsnap;dxGaugeControlRS20;dxSpreadSheetReportDesignerRS20;dxSkinDevExpressStyleRS20;fmxFireDAC;cxPivotGridChartRS20;DBXDb2Driver;DBXOracleDriver;dxSkinOffice2010BlueRS20;vclribbon;cxExportRS20;dxServerModeRS20;dxSkinscxSchedulerPainterRS20;dxSkinMetropolisDarkRS20;fmxase;vcl;DBXMSSQLDriver;IndyIPCommon;CodeSiteExpressPkg;dxSkinBlueRS20;dxSkinOffice2010BlackRS20;DataSnapFireDAC;FireDACDBXDriver;dxBarExtDBItemsRS20;dxSkinsdxDLPainterRS20;soapserver;dxPSDBTeeChartRS20;dxHttpIndyRequestRS20;inetdbxpress;dxADOServerModeRS20;dxSkinBlueprintRS20;dxSkinFoggyRS20;dxSkinSharpPlusRS20;FireDACInfxDriver;cxPivotGridRS20;adortl;dxSkinOffice2016ColorfulRS20;dxRibbonRS20;FireDACASADriver;dxSkinHighContrastRS20;dxSkinTheAsphaltWorldRS20;dxBarDBNavRS20;dxSkinscxPCPainterRS20;rtl;DbxClientDriver;dxSkinMetropolisRS20;dxNavBarRS20;dxDockingRS20;Tee;dxSkinOffice2007BlueRS20;dxSkinsdxRibbonPainterRS20;dxSkinValentineRS20;DataSnapNativeClient;svnui;IndyProtocols;DBXMySQLDriver;dxSkinSevenClassicRS20;dxPScxCommonRS20;dxSkinPumpkinRS20;bindcompdbx;TeeUI;dxSkinDarkRoomRS20;FireDACADSDriver;vcltouch;dxSkinStardustRS20;cxEditorsRS20;dxorgcRS20;dxPSdxDBOCLnkRS20;VclSmp;FireDAC;VCLRESTComponents;dxSkinsCoreRS20;DataSnapConnectors;dxSkinSevenRS20;cxLibraryRS20;fmxobj;dxMapControlRS20;svn;dxWizardControlRS20;dxSkinLilianRS20;FireDACOracleDriver;fmxdae;dxSkinWhiteprintRS20;dxPScxPivotGridLnkRS20;bdertl;dxThemeRS20;dxPSdxOCLnkRS20;cxTreeListRS20;dxTileControlRS20;FireDACMSAccDriver;DataSnapIndy10ServerTransport;$(DCC_UsePackage)</DCC_UsePackage>
6775
<VerInfo_Locale>1033</VerInfo_Locale>
6876
<DCC_Namespace>Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace)</DCC_Namespace>
69-
<VerInfo_Keys>CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
7077
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
7178
</PropertyGroup>
7279
<PropertyGroup Condition="'$(Base_Win64)'!=''">
@@ -82,7 +89,6 @@
8289
</PropertyGroup>
8390
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
8491
<VerInfo_Locale>1033</VerInfo_Locale>
85-
<Manifest_File>None</Manifest_File>
8692
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
8793
<DCC_RemoteDebug>false</DCC_RemoteDebug>
8894
</PropertyGroup>
@@ -92,6 +98,10 @@
9298
<DCC_SymbolReferenceInfo>0</DCC_SymbolReferenceInfo>
9399
<DCC_DebugInformation>0</DCC_DebugInformation>
94100
</PropertyGroup>
101+
<PropertyGroup Condition="'$(Cfg_2_Win32)'!=''">
102+
<VerInfo_Locale>1033</VerInfo_Locale>
103+
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
104+
</PropertyGroup>
95105
<ItemGroup>
96106
<DelphiCompile Include="$(MainSource)">
97107
<MainSource>MainSource</MainSource>

‎TestDllPas/UnitMainDll.pas

-3
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,10 @@ initialization
2828
g_TImplCppOrdine := nil;
2929
end;
3030

31-
3231
finalization
3332

3433
begin
35-
3634
g_TImplCppOrdine.Free;
3735
end;
3836

3937
end.
40-

0 commit comments

Comments
 (0)
Please sign in to comment.