Defining []NA call that requires a pointer to a pointer.

Using (or providing) components based on the "Win32" framework

Defining []NA call that requires a pointer to a pointer.

Postby norbertjurkiewicz84 on Tue Jan 07, 2014 9:25 pm

What's the best way to define this. I have a function that takes 2 arguments, see def. below.

int GetErrorMsg(int ErrorNo, char **errMsg)

I'm sure I can go the route of global alloc but is there a clean way to get this sting back?
(It's the little things that make the difference :-)
User avatar
norbertjurkiewicz84
 
Posts: 62
Joined: Mon Nov 01, 2010 7:26 pm

Re: Defining []NA call that requires a pointer to a pointer.

Postby Vince|Dyalog on Wed Jan 08, 2014 11:56 am

Hi Norbert,

On MS Windows and a Dyalog 32-bit Unicode, I think the following will get you what you want.

⎕NA 'I4 thedll.dll|GetErrorMsg <0T P'

errMsg is a double indirect—as you mention, a pointer to a pointer.

To read errMsg, you’ll need to use the MEMCPY and STRNCPY techniques as shown in the ⎕NA documentation.

e.g.
'addrget' ⎕NA 'dyalog32|MEMCPY >P[] P U4'
addrget 1 ppaddr 4 ⍝ Where ppaddr is the char** errMsg from GetErrorMsg

The above gets a pointer to a character string so that we can pass it to STRNCPY:

'strget' ⎕NA 'dyalog32|STRNCPY* >0T1[] P U4'

Regards,

Vince
Vince|Dyalog
 
Posts: 412
Joined: Wed Oct 01, 2008 9:39 am


Return to Windows: GUI, COM/OLE/ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest