c++ STRUCTURE data types

c++ STRUCTURE data types

Postby don lowenstein » Tue Jul 17, 2018 1: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
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: c++ STRUCTURE data types

Postby Antonio Linares » Wed Jul 18, 2018 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: c++ STRUCTURE data types

Postby don lowenstein » Wed Jul 18, 2018 8:25 pm

where in the code does this go?
do you have a small code snippet?
Don Lowenstein
www.laapc.com
User avatar
don lowenstein
 
Posts: 197
Joined: Mon Oct 17, 2005 9:09 pm

Re: c++ STRUCTURE data types

Postby Antonio Linares » Wed Jul 18, 2018 8: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42065
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 54 guests

cron