FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour c++ STRUCTURE data types
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
c++ STRUCTURE data types
Posted: Tue Jul 17, 2018 01:26 PM

I need to call a 64-bit dll with the following parms:

c++ call:

SOCKET WINAPI InetConnect(
LPCTSTR lpszHostName,
UINT nPort,
UINT nProtocol,
UINT nTimeout,
DWORD dwOptions,
LPSECURITYCREDENTIALS lpCredentials
);

The LPSECURITYCREDENTIALS data type is a user defined c++ structure:

typedef struct _SECURITYCREDENTIALS
{
DWORD dwSize;
DWORD dwProtocol;
DWORD dwOptions;
DWORD dwReserved;
LPCTSTR lpszHostName;
LPCTSTR lpszUserName;
LPCTSTR lpszPassword;
LPCTSTR lpszCertStore;
LPCTSTR lpszCertName;
LPCTSTR lpszKeyFile;
} SECURITYCREDENTIALS, *LPSECURITYCREDENTIALS;


Harbour / Fivewin equivalent:
DLL32 FUNCTION InetConnect( lpszHostName AS LPSTR, ;
nPort AS _INT, ;
nProtocol AS _INT, ;
nTimeout AS _INT, ;
dwOptions AS DWORD, ;
lpCredentials AS LPSECURITYCREDENTIALS ) ;
AS LONG ;
PASCAL FROM "InetConnectA" ;
LIB M->HDLL

My question is, how would I create a LPSECURITYCREDENTIALS data variable for passing to the DLL32 FUNCTION?

Then, I need to populate:
LPSECURITYCREDENTIALS.lpszCertStore
LPSECURITYCREDENTIALS.lpszCertName

Thanks in advance.

don


Don Lowenstein
www.laapc.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: c++ STRUCTURE data types
Posted: Wed Jul 18, 2018 06:39 PM

Don,

@lpCredentials AS PTR

STRUCT oCredentials
MEMBER dwSize AS DWORD
MEMBER dwProtocol AS DWORD
MEMBER dwOptions AS DWORD
MEMBER dwReserved AS DWORD
MEMBER lpszHostName AS LPSTR
MEMBER lpszUserName AS LPSTR
MEMBER lpszPassword AS LPSTR
MEMBER lpszCertStore AS LPSTR
MEMBER lpszCertName AS LPSTR
MEMBER lpszKeyFile AS LPSTR
ENDSTRUCT

@oCredentials:cBuffer

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 204
Joined: Mon Oct 17, 2005 09:09 PM
Re: c++ STRUCTURE data types
Posted: Wed Jul 18, 2018 08:25 PM

where in the code does this go?
do you have a small code snippet?

Don Lowenstein
www.laapc.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: c++ STRUCTURE data types
Posted: Wed Jul 18, 2018 08:38 PM

STRUCT oCredentials
MEMBER dwSize AS DWORD
MEMBER dwProtocol AS DWORD
MEMBER dwOptions AS DWORD
MEMBER dwReserved AS DWORD
MEMBER lpszHostName AS LPSTR
MEMBER lpszUserName AS LPSTR
MEMBER lpszPassword AS LPSTR
MEMBER lpszCertStore AS LPSTR
MEMBER lpszCertName AS LPSTR
MEMBER lpszKeyFile AS LPSTR
ENDSTRUCT

oCredentials:dwSize = oCredentials:SizeOf()
oCredentials:lpszCertStore = cCertStore
oCredentials:lpszCertName = cCertName

INetConnect( ..., ..., ..., ..., ..., @oCredentials:cBuffer )

...

DLL32 FUNCTION InetConnect( lpszHostName AS LPSTR, ;
nPort AS _INT, ;
nProtocol AS _INT, ;
nTimeout AS _INT, ;
dwOptions AS DWORD, ;
@lpCredentials AS PTR ) ;
AS LONG ;
PASCAL FROM "InetConnectA" ;
LIB M->HDLL

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion